Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ static avifResult avifImageCopyProperties(avifImage * dstImage, const avifImage
dstImage->numProperties = 0;

if (srcImage->numProperties != 0) {
AVIF_CHECKERR(srcImage->numProperties < SIZE_MAX / sizeof(srcImage->properties[0]), AVIF_RESULT_INVALID_ARGUMENT);
dstImage->properties = (avifImageItemProperty *)avifAlloc(srcImage->numProperties * sizeof(srcImage->properties[0]));
AVIF_CHECKERR(dstImage->properties != NULL, AVIF_RESULT_OUT_OF_MEMORY);
memset(dstImage->properties, 0, srcImage->numProperties * sizeof(srcImage->properties[0]));
Expand Down
6 changes: 6 additions & 0 deletions src/codec_avm.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,13 @@ static avifResult avmCodecEncodeImage(avifCodec * codec,
// Allocate the U plane if necessary.
if (!avmImageAllocated) {
uint32_t channelSize = avifImageUsesU16(image) ? 2 : 1;
if (monoUVWidth > UINT32_MAX / channelSize) {
return AVIF_RESULT_INVALID_ARGUMENT;
}
uint32_t monoUVRowBytes = channelSize * monoUVWidth;
if (monoUVHeight > PTRDIFF_MAX / monoUVRowBytes) {
return AVIF_RESULT_INVALID_ARGUMENT;
}
size_t monoUVSize = (size_t)monoUVHeight * monoUVRowBytes;

monoUVPlane = avifAlloc(monoUVSize);
Expand Down
6 changes: 6 additions & 0 deletions src/codec_svt.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,13 @@ static avifResult svtCodecEncodeImage(avifCodec * codec,
#if SVT_AV1_CHECK_VERSION(1, 8, 0)
// Simulate 4:2:0 UV planes. SVT-AV1 does not support 4:0:0 samples.
const uint32_t uvWidth = (image->width + y_shift) >> y_shift;
if (uvWidth > UINT32_MAX / bytesPerPixel) {
goto cleanup;
}
const uint32_t uvRowBytes = uvWidth * bytesPerPixel;
if (uvHeight > PTRDIFF_MAX / uvRowBytes) {
goto cleanup;
}
const size_t uvSize = (size_t)uvRowBytes * uvHeight;
if (uvSize > UINT32_MAX / 2) {
goto cleanup;
Expand Down
Loading