Fix use after free
This commit is contained in:
parent
9459186125
commit
28a9a181cb
1 changed files with 30 additions and 29 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue