Skip to content

Commit 7be49a4

Browse files
y-guyonGerrit Code Review
authored andcommitted
Merge "Null out derived sub-slice pointers in VP8LClear" into main
2 parents 61a65c8 + d2c066f commit 7be49a4

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/dec/vp8l_dec.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,8 @@ static void VP8LClear(VP8LDecoder* const dec) {
15091509

15101510
WebPSafeFree(dec->pixels);
15111511
dec->pixels = NULL;
1512+
dec->argb_cache = NULL;
1513+
dec->accumulated_rgb_pixels = NULL;
15121514
for (i = 0; i < dec->next_transform; ++i) {
15131515
ClearTransform(&dec->transforms[i]);
15141516
}
@@ -1646,7 +1648,10 @@ static int AllocateInternalBuffers32b(VP8LDecoder* const dec, int final_width) {
16461648
assert(dec->width <= final_width);
16471649
dec->pixels = (uint32_t*)WebPSafeMalloc(total_num_pixels, sizeof(uint32_t));
16481650
if (dec->pixels == NULL) {
1649-
dec->argb_cache = NULL; // for soundness
1651+
// Clear sub-slice pointers derived from dec->pixels to prevent dangling
1652+
// references.
1653+
dec->argb_cache = NULL;
1654+
dec->accumulated_rgb_pixels = NULL;
16501655
return VP8LSetError(dec, VP8_STATUS_OUT_OF_MEMORY);
16511656
}
16521657
dec->argb_cache = dec->pixels + num_pixels + cache_top_pixels;
@@ -1661,7 +1666,10 @@ static int AllocateInternalBuffers32b(VP8LDecoder* const dec, int final_width) {
16611666

16621667
static int AllocateInternalBuffers8b(VP8LDecoder* const dec) {
16631668
const uint64_t total_num_pixels = (uint64_t)dec->width * dec->height;
1664-
dec->argb_cache = NULL; // for soundness
1669+
// Clear sub-slice pointers derived from dec->pixels to prevent dangling
1670+
// references.
1671+
dec->argb_cache = NULL;
1672+
dec->accumulated_rgb_pixels = NULL;
16651673
dec->pixels = (uint32_t*)WebPSafeMalloc(total_num_pixels, sizeof(uint8_t));
16661674
if (dec->pixels == NULL) {
16671675
return VP8LSetError(dec, VP8_STATUS_OUT_OF_MEMORY);

0 commit comments

Comments
 (0)