diff --git a/libheif/file.cc b/libheif/file.cc index 39d4795649..8a678bf92a 100644 --- a/libheif/file.cc +++ b/libheif/file.cc @@ -1024,8 +1024,10 @@ Error HeifFile::set_item_data(const std::shared_ptr& item, const uint8 else { // uncompressed data, plain copy - data_array.resize(size); - memcpy(data_array.data(), data, size); + if (size > 0) { // Note: this 'if' is not necessary, but a workaround to a compiler bug (https://github.com/strukturag/libheif/issues/1421) + data_array.resize(size); + memcpy(data_array.data(), data, size); + } } // copy the data into the file, store the pointer to it in an iloc box entry