summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorSasLuca <[email protected]>2020-02-11 21:25:27 +0000
committerGitHub <[email protected]>2020-02-11 22:25:27 +0100
commitdec85f741a1605b58e7ae819cbbb9bd82f16e60d (patch)
treef1de8f1a0f138e1815f536b9e8c1c365177f7aaf /src
parent87d5b51256118cdf00c8d6c02133b0f65c52fcca (diff)
downloadraylib-dec85f741a1605b58e7ae819cbbb9bd82f16e60d.tar.gz
raylib-dec85f741a1605b58e7ae819cbbb9bd82f16e60d.zip
Fixed memory leaks in textures.c (#1097)
Diffstat (limited to 'src')
-rw-r--r--src/textures.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/textures.c b/src/textures.c
index 7e98f178..ade4acfa 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -953,8 +953,6 @@ void ImageToPOT(Image *image, Color fillColor)
// Security check to avoid program crash
if ((image->data == NULL) || (image->width == 0) || (image->height == 0)) return;
- Color *pixels = GetImageData(*image); // Get pixels data
-
// Calculate next power-of-two values
// NOTE: Just add the required amount of pixels at the right and bottom sides of image...
int potWidth = (int)powf(2, ceilf(logf((float)image->width)/logf(2)));
@@ -963,6 +961,7 @@ void ImageToPOT(Image *image, Color fillColor)
// Check if POT texture generation is required (if texture is not already POT)
if ((potWidth != image->width) || (potHeight != image->height))
{
+ Color *pixels = GetImageData(*image); // Get pixels data
Color *pixelsPOT = NULL;
// Generate POT array from NPOT data
@@ -1239,6 +1238,7 @@ void ImageAlphaClear(Image *image, Color color, float threshold)
*image = LoadImageEx(pixels, image->width, image->height);
ImageFormat(image, prevFormat);
+ RL_FREE(pixels);
}
// Premultiply alpha channel
@@ -1264,6 +1264,7 @@ void ImageAlphaPremultiply(Image *image)
*image = LoadImageEx(pixels, image->width, image->height);
ImageFormat(image, prevFormat);
+ RL_FREE(pixels);
}
#if defined(SUPPORT_IMAGE_MANIPULATION)