Validate the |border| parameter earlier.
aom_realloc_frame_buffer() should validate the |border| parameter
earlier, before it allocates the buffer and preferrably before it uses
|border|.
Change-Id: Id14fe9dd54333ed32bc6b4f479b7892e8dbc912b
diff --git a/aom_scale/generic/yv12config.c b/aom_scale/generic/yv12config.c
index 84705e2..cd5dbea 100644
--- a/aom_scale/generic/yv12config.c
+++ b/aom_scale/generic/yv12config.c
@@ -55,6 +55,13 @@
if (width > DECODE_WIDTH_LIMIT || height > DECODE_HEIGHT_LIMIT) return -1;
#endif
+ /* Only support allocating buffers that have a border that's a multiple
+ * of 32. The border restriction is required to get 16-byte alignment of
+ * the start of the chroma rows without introducing an arbitrary gap
+ * between planes, which would break the semantics of things like
+ * aom_img_set_rect(). */
+ if (border & 0x1f) return -3;
+
if (ybf) {
const int aom_byte_align = (byte_alignment == 0) ? 1 : byte_alignment;
const int aligned_width = (width + 7) & ~7;
@@ -127,13 +134,6 @@
memset(ybf->buffer_alloc, 0, ybf->buffer_alloc_sz);
}
- /* Only support allocating buffers that have a border that's a multiple
- * of 32. The border restriction is required to get 16-byte alignment of
- * the start of the chroma rows without introducing an arbitrary gap
- * between planes, which would break the semantics of things like
- * aom_img_set_rect(). */
- if (border & 0x1f) return -3;
-
ybf->y_crop_width = width;
ybf->y_crop_height = height;
ybf->y_width = aligned_width;