shithub: libvpx

Download patch

ref: efbab73cc1f1c21e39adcbf401ab9cd60523330c
parent: 1710f6507d7f9e23f23912e5f2fe439300c0bfd6
author: James Zern <jzern@google.com>
date: Wed Feb 17 07:41:08 EST 2016

vp9_resize: add missing alloc checks

Change-Id: I87ef6dec7cd2e8f9a40135e5ca11b13520ebd6d7

--- a/vp9/encoder/vp9_resize.c
+++ b/vp9/encoder/vp9_resize.c
@@ -462,6 +462,7 @@
     int filteredlength = length;
     if (!tmpbuf) {
       tmpbuf = (uint8_t *)malloc(sizeof(uint8_t) * length);
+      if (tmpbuf == NULL) return;
       otmp = tmpbuf;
     } else {
       otmp = buf;
@@ -521,6 +522,7 @@
   uint8_t *tmpbuf = (uint8_t *)malloc(sizeof(uint8_t) *
                                       (width < height ? height : width));
   uint8_t *arrbuf = (uint8_t *)malloc(sizeof(uint8_t) * (height + height2));
+  if (intbuf == NULL || tmpbuf == NULL || arrbuf == NULL) goto Error;
   assert(width > 0);
   assert(height > 0);
   assert(width2 > 0);
@@ -533,6 +535,8 @@
     resize_multistep(arrbuf, height, arrbuf + height, height2, tmpbuf);
     fill_arr_to_col(output + i, out_stride, height2, arrbuf + height);
   }
+
+ Error:
   free(intbuf);
   free(tmpbuf);
   free(arrbuf);
@@ -755,6 +759,7 @@
     int filteredlength = length;
     if (!tmpbuf) {
       tmpbuf = (uint16_t *)malloc(sizeof(uint16_t) * length);
+      if (tmpbuf == NULL) return;
       otmp = tmpbuf;
     } else {
       otmp = buf;
@@ -817,6 +822,7 @@
   uint16_t *tmpbuf = (uint16_t *)malloc(sizeof(uint16_t) *
                                         (width < height ? height : width));
   uint16_t *arrbuf = (uint16_t *)malloc(sizeof(uint16_t) * (height + height2));
+  if (intbuf == NULL || tmpbuf == NULL || arrbuf == NULL) goto Error;
   for (i = 0; i < height; ++i) {
     highbd_resize_multistep(CONVERT_TO_SHORTPTR(input + in_stride * i), width,
                             intbuf + width2 * i, width2, tmpbuf, bd);
@@ -828,6 +834,8 @@
     highbd_fill_arr_to_col(CONVERT_TO_SHORTPTR(output + i), out_stride, height2,
                            arrbuf + height);
   }
+
+ Error:
   free(intbuf);
   free(tmpbuf);
   free(arrbuf);