Skip to content

Commit

Permalink
libavif_jni: add missing error check (AOMediaCodec#2508)
Browse files Browse the repository at this point in the history
`image_copy` is reset with the result of `avifImageCreateEmpty()` which
can fail. This change adds a check to match the one used for
`cropped_image`.
  • Loading branch information
jzern authored Nov 20, 2024
1 parent 566e2ed commit 03738d5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions android_jni/avifandroidjni/src/main/jni/libavif_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ avifResult AvifImageToBitmap(JNIEnv* const env,
// scaling.
if (!image->imageOwnsYUVPlanes || !image->imageOwnsAlphaPlane) {
image_copy.reset(avifImageCreateEmpty());
if (image_copy == nullptr) {
LOGE("Failed to allocate image for scaling.");
return AVIF_RESULT_OUT_OF_MEMORY;
}
res = avifImageCopy(image_copy.get(), image, AVIF_PLANES_ALL);
if (res != AVIF_RESULT_OK) {
LOGE("Failed to make a copy of the image for scaling. Status: %d", res);
Expand Down

0 comments on commit 03738d5

Please sign in to comment.