From 787868684772124835dcbcee0e1d64ece79d86f2 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Mon, 16 Dec 2024 23:19:05 +0100 Subject: [PATCH] fix checking error return value from HeifPixelImage::add_channel() (#1426) --- libheif/api/libheif/heif.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libheif/api/libheif/heif.cc b/libheif/api/libheif/heif.cc index 3b7ce8532f..bd83e851d3 100644 --- a/libheif/api/libheif/heif.cc +++ b/libheif/api/libheif/heif.cc @@ -1821,11 +1821,8 @@ struct heif_error heif_image_add_channel(struct heif_image* image, int width, int height, heif_channel_datatype datatype, int bit_depth) { - if (!image->image->add_channel(channel, width, height, datatype, bit_depth, nullptr)) { - struct heif_error err = {heif_error_Memory_allocation_error, - heif_suberror_Unspecified, - "Cannot allocate memory for image plane"}; - return err; + if (auto err = image->image->add_channel(channel, width, height, datatype, bit_depth, nullptr)) { + return err.error_struct(image->image.get()); } else { return heif_error_success;