Skip to content

Commit

Permalink
Fix leak when rescaling images
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Jan 16, 2024
1 parent b593816 commit faefa9f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion graphics/src/Image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,17 @@ BOOL Image::Implementation::PixelIndex(
//////////////////////////////////////////////////
void Image::Rescale(int _width, int _height)
{
this->dataPtr->bitmap = FreeImage_Rescale(
auto *scaled = FreeImage_Rescale(
this->dataPtr->bitmap, _width, _height, FILTER_LANCZOS3);

if (!scaled)
{
gzerr << "Failed to rescale image\n";
return;

Check warning on line 697 in graphics/src/Image.cc

View check run for this annotation

Codecov / codecov/patch

graphics/src/Image.cc#L696-L697

Added lines #L696 - L697 were not covered by tests
}

FreeImage_Unload(this->dataPtr->bitmap);
this->dataPtr->bitmap = scaled;
}

//////////////////////////////////////////////////
Expand Down

0 comments on commit faefa9f

Please sign in to comment.