Skip to content

Commit

Permalink
Merge pull request #1416 from dlemstra/windows-debug-build-fix
Browse files Browse the repository at this point in the history
Patch to avoid out of bounds assert with a debug build on Windows.
  • Loading branch information
farindk authored Dec 5, 2024
2 parents 5385aa7 + 0ea0d77 commit fa8082f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libheif/plugins/decoder_openh264.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ struct heif_error openh264_decode_image(void* decoder_raw, struct heif_image** o
std::vector<uint8_t> scdata;

size_t idx = 0;
auto end = &indata[0];
while (idx < indata.size()) {
if (indata.size() - 4 < idx) {
return kError_EOF;
Expand Down Expand Up @@ -162,7 +163,8 @@ struct heif_error openh264_decode_image(void* decoder_raw, struct heif_image** o
scdata.push_back(0);
scdata.push_back(3);

scdata.insert(scdata.end(), &indata[idx + 2], &indata[idx + i + 2]);
end = (&indata[idx + i + 1])+1;
scdata.insert(scdata.end(), &indata[idx + 2], end);
idx += i + 2;
size -= (uint32_t)(i + 2);
found_start_code_emulation = true;
Expand All @@ -174,7 +176,8 @@ struct heif_error openh264_decode_image(void* decoder_raw, struct heif_image** o
}

assert(size > 0);
scdata.insert(scdata.end(), &indata[idx], &indata[idx + size]);
end = (&indata[idx + size - 1])+1;
scdata.insert(scdata.end(), &indata[idx], end);

idx += size;
}
Expand Down

0 comments on commit fa8082f

Please sign in to comment.