Skip to content

Commit

Permalink
Check memory allocations.
Browse files Browse the repository at this point in the history
  • Loading branch information
maryla-uc committed Dec 4, 2023
1 parent a42fed5 commit 4721a2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/avifgainmaputil/convert_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ avifResult ConvertCommand::Run() {
// If there is no ICC and no CICP, assume sRGB by default.
image->colorPrimaries = AVIF_COLOR_PRIMARIES_SRGB;
image->transferCharacteristics = AVIF_TRANSFER_CHARACTERISTICS_SRGB;
image->gainMap->altColorPrimaries = AVIF_COLOR_PRIMARIES_BT709;
image->gainMap->altColorPrimaries = AVIF_COLOR_PRIMARIES_SRGB;
}

if (image->gainMap == nullptr || image->gainMap->image == nullptr) {
Expand All @@ -79,6 +79,9 @@ avifResult ConvertCommand::Run() {
depth = image->gainMap->metadata.alternateHdrHeadroomN == 0 ? 8 : 10;
}
ImagePtr new_base(avifImageCreateEmpty());
if (new_base == nullptr) {
return AVIF_RESULT_OUT_OF_MEMORY;
}
const avifResult result =
ChangeBase(*image, depth, image->yuvFormat, new_base.get());
if (result != AVIF_RESULT_OK) {
Expand Down
3 changes: 3 additions & 0 deletions apps/avifgainmaputil/swapbase_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ avifResult SwapBaseCommand::Run() {
}

ImagePtr new_base(avifImageCreateEmpty());
if (new_base == nullptr) {
return AVIF_RESULT_OUT_OF_MEMORY;
}
result = ChangeBase(*image, depth, pixel_format, new_base.get());
if (result != AVIF_RESULT_OK) {
return result;
Expand Down

0 comments on commit 4721a2e

Please sign in to comment.