Fix parameter check in bFile::safeSwapPtr

If either the source or destination pointers are nullptr, we shouldn't continue otherwise we dereference nullptr or memcpy with nullptr which is undefined.

(Also move the check to return as soon as possible.)
This commit is contained in:
Andy Maloney
2020-06-13 10:59:16 -04:00
parent da50438c3c
commit 2197101bc5

View File

@@ -851,12 +851,12 @@ void bFile::swapData(char *data, short type, int arraySize, bool ignoreEndianFla
void bFile::safeSwapPtr(char *dst, const char *src)
{
if (!src || !dst)
return;
int ptrFile = mFileDNA->getPointerSize();
int ptrMem = mMemoryDNA->getPointerSize();
if (!src && !dst)
return;
if (ptrFile == ptrMem)
{
memcpy(dst, src, ptrMem);