Commit 6d141ecf authored by Maik Qualmann's avatar Maik Qualmann

check for allocate memory

parent fbad9b49
......@@ -321,6 +321,7 @@ bool DImgHEIFLoader::readHEICImageByID(struct heif_context* const heif_context,
if (!isHeifSuccess(&error))
{
loadingFailed();
heif_context_free(heif_context);
return false;
......@@ -355,6 +356,7 @@ bool DImgHEIFLoader::readHEICImageByID(struct heif_context* const heif_context,
if (!isHeifSuccess(&error))
{
loadingFailed();
heif_image_handle_release(image_handle);
heif_context_free(heif_context);
......@@ -413,6 +415,7 @@ bool DImgHEIFLoader::readHEICImageByHandle(struct heif_image_handle* image_handl
if (!isHeifSuccess(&error))
{
loadingFailed();
heif_image_handle_release(image_handle);
return false;
......@@ -439,6 +442,7 @@ bool DImgHEIFLoader::readHEICImageByHandle(struct heif_image_handle* image_handl
if (!QSize(imageWidth(), imageHeight()).isValid())
{
loadingFailed();
heif_image_release(heif_image);
heif_image_handle_release(image_handle);
......@@ -454,6 +458,7 @@ bool DImgHEIFLoader::readHEICImageByHandle(struct heif_image_handle* image_handl
if (!ptr || stride <= 0)
{
qWarning() << "HEIC data pixels information not valid!";
loadingFailed();
heif_image_release(heif_image);
heif_image_handle_release(image_handle);
......@@ -478,6 +483,7 @@ bool DImgHEIFLoader::readHEICImageByHandle(struct heif_image_handle* image_handl
else
{
qWarning() << "Color bits depth: " << colorDepth << ": not supported!";
loadingFailed();
heif_image_release(heif_image);
heif_image_handle_release(image_handle);
......@@ -495,6 +501,16 @@ bool DImgHEIFLoader::readHEICImageByHandle(struct heif_image_handle* image_handl
data = new_failureTolerant(imageWidth(), imageHeight(), 4); // 8 bits/color/pixel
}
if (!data)
{
qWarning() << "Cannot allocate memory!";
loadingFailed();
heif_image_release(heif_image);
heif_image_handle_release(image_handle);
return false;
}
if (m_observer)
{
m_observer->progressInfo(0.4F);
......@@ -569,11 +585,10 @@ bool DImgHEIFLoader::readHEICImageByHandle(struct heif_image_handle* image_handl
if (!m_observer->continueQuery())
{
loadingFailed();
heif_image_release(heif_image);
heif_image_handle_release(image_handle);
loadingFailed();
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment