Skip to content

Commit

Permalink
updated stbimage load routines to remove potential memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacey committed Oct 6, 2023
1 parent c247424 commit 9b5b2a9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,9 @@ bool Image::load(std::string_view _fname,bool _flipY) noexcept
}
m_data=std::make_unique< unsigned char []>(m_width * m_height * m_channels);
memcpy(m_data.get(), img, m_width * m_height * m_channels);
return true;
}
else
else if(img == nullptr)
{
NGLMessage::addError("Image load failed this version only supports PNG,JPEG,GIF,TGA,BMP ");
NGLMessage::addError("Have generated a Red Checkerboard pattern instead.");
Expand Down Expand Up @@ -422,9 +423,14 @@ bool Image::load(std::string_view _fname,bool _flipY) noexcept
}
}
}
}
return true;

return true;
}
else
{
return false;
}

}
#endif
} // namespace ngl

0 comments on commit 9b5b2a9

Please sign in to comment.