diff options
author | Vikas Arora <vikasa@google.com> | 2013-03-13 16:43:18 -0700 |
---|---|---|
committer | Vikas Arora <vikasa@google.com> | 2013-03-14 10:15:22 -0700 |
commit | 1e7bf8805bd030c19924a5306837ecd72c295751 (patch) | |
tree | 20a7189518b1824f7805016e9718e26e9c3a6668 /src/utils/utils.c | |
parent | b6dbce6bfeaabde2a7b581c4c6888d532d32f3ac (diff) | |
download | webp-1e7bf8805bd030c19924a5306837ecd72c295751.tar.gz |
Sync-patch with libwebp (ChangeId: Ia5475247)android-4.3_r3.1android-4.3_r3android-4.3_r2.3android-4.3_r2.2android-4.3_r2.1android-4.3_r2android-4.3_r1.1android-4.3_r1android-4.3_r0.9.1android-4.3_r0.9android-4.3.1_r1tools_r22.2jb-mr2.0.0-releasejb-mr2.0-releasejb-mr2-releasejb-mr2-dev
Added 16bit swapping of RGB565 / RGB4444 colorspace.
Added ARM/NEON code for decoder/encoder modules.
Speedup in WebP compression (method 3 and above).
Change-Id: I95a697338bef7c3ea08054eb5f850a97d1889eb9
Diffstat (limited to 'src/utils/utils.c')
-rw-r--r-- | src/utils/utils.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/utils/utils.c b/src/utils/utils.c index 673b7e28..b1db2f9d 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -19,7 +19,8 @@ extern "C" { //------------------------------------------------------------------------------ // Checked memory allocation -static int CheckSizeArguments(uint64_t nmemb, size_t size) { +// Returns 0 in case of overflow of nmemb * size. +static int CheckSizeArgumentsOverflow(uint64_t nmemb, size_t size) { const uint64_t total_size = nmemb * size; if (nmemb == 0) return 1; if ((uint64_t)size > WEBP_MAX_ALLOCABLE_MEMORY / nmemb) return 0; @@ -28,12 +29,14 @@ static int CheckSizeArguments(uint64_t nmemb, size_t size) { } void* WebPSafeMalloc(uint64_t nmemb, size_t size) { - if (!CheckSizeArguments(nmemb, size)) return NULL; + if (!CheckSizeArgumentsOverflow(nmemb, size)) return NULL; + assert(nmemb * size > 0); return malloc((size_t)(nmemb * size)); } void* WebPSafeCalloc(uint64_t nmemb, size_t size) { - if (!CheckSizeArguments(nmemb, size)) return NULL; + if (!CheckSizeArgumentsOverflow(nmemb, size)) return NULL; + assert(nmemb * size > 0); return calloc((size_t)nmemb, size); } |