Fixes handlong of loading non-DDS images to better handle pointer references with the GBitmap resources.

Also adds a sanity check for the source or dest strings so they can't be empty strings
This commit is contained in:
JeffR 2022-03-06 22:55:05 -06:00
parent 21c72f6b53
commit f1f73e41bd

View file

@ -1368,6 +1368,11 @@ DefineEngineFunction(saveScaledImage, bool, (const char* bitmapSource, const cha
{
bool isDDS = false;
if (bitmapSource == 0 || bitmapSource[0] == '\0' || bitmapDest == 0 || bitmapDest[0] == '\0')
{
return false;
}
//First, gotta check the extension, as we have some extra work to do if it's
//a DDS file
const char* ret = dStrrchr(bitmapSource, '.');
@ -1381,7 +1386,7 @@ DefineEngineFunction(saveScaledImage, bool, (const char* bitmapSource, const cha
return false; //no extension? bail out
}
GBitmap* image;
GBitmap* image = NULL;
if (isDDS)
{
Resource<DDSFile> dds = DDSFile::load(bitmapSource, 0);
@ -1397,7 +1402,8 @@ DefineEngineFunction(saveScaledImage, bool, (const char* bitmapSource, const cha
}
else
{
image = GBitmap::load(bitmapSource);
Resource<GBitmap> resImage = GBitmap::load(bitmapSource);
image = new GBitmap(*resImage);
}
if (!image)