ref: 1c792f2991e632be26414ecb62835bf148c086b4
parent: 72dc6478ac65dbf8b9c4b14c52937396a7bd24b4
author: James Zern <jzern@google.com>
date: Thu Apr 8 13:34:16 EDT 2021
vpx_image: clear user provided vpx_image_t early this avoids uninitialized values and potential misuse of them which could lead to a crash should the function fail this is the same fix that was applied in libaom: d0cac70b5 Fix a free on invalid ptr when img allocation fails Bug: webm:1722 Change-Id: If7a8d08c4b010f12e2e1d848613c0fa7328f1f9c
--- a/vpx/src/vpx_image.c
+++ b/vpx/src/vpx_image.c
@@ -24,6 +24,8 @@
unsigned int stride_in_bytes;
int align;
+ if (img != NULL) memset(img, 0, sizeof(vpx_image_t));
+
/* Treat align==0 like align==1 */
if (!buf_align) buf_align = 1;
@@ -88,8 +90,6 @@
if (!img) goto fail;
img->self_allocd = 1;
- } else {
- memset(img, 0, sizeof(vpx_image_t));
}
img->img_data = img_data;