mirror of
https://github.com/raysan5/raylib.git
synced 2025-10-08 19:06:27 +00:00
Fix use after free
This commit is contained in:
@@ -677,7 +677,7 @@ void ImageFormat(Image *image, int newFormat)
|
|||||||
Color *pixels = GetImageData(*image);
|
Color *pixels = GetImageData(*image);
|
||||||
|
|
||||||
free(image->data); // WARNING! We loose mipmaps data --> Regenerated at the end...
|
free(image->data); // WARNING! We loose mipmaps data --> Regenerated at the end...
|
||||||
|
image->data = NULL;
|
||||||
image->format = newFormat;
|
image->format = newFormat;
|
||||||
|
|
||||||
int k = 0;
|
int k = 0;
|
||||||
@@ -824,12 +824,13 @@ void ImageFormat(Image *image, int newFormat)
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(pixels);
|
free(pixels);
|
||||||
|
pixels = NULL;
|
||||||
// In case original image had mipmaps, generate mipmaps for formated image
|
// In case original image had mipmaps, generate mipmaps for formated image
|
||||||
// NOTE: Original mipmaps are replaced by new ones, if custom mipmaps were used, they are lost
|
// NOTE: Original mipmaps are replaced by new ones, if custom mipmaps were used, they are lost
|
||||||
if (image->mipmaps > 1)
|
if (image->mipmaps > 1)
|
||||||
{
|
{
|
||||||
image->mipmaps = 1;
|
image->mipmaps = 1;
|
||||||
|
assert(image->data != NULL);
|
||||||
ImageMipmaps(image);
|
ImageMipmaps(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user