summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Maloney <asmaloney@gmail.com>2020-06-13 10:59:16 -0400
committerAndy Maloney <asmaloney@gmail.com>2020-06-13 10:59:16 -0400
commit2197101bc568a90e7af3bdd49280d4007200aab2 (patch)
tree173b65f2bb1dfebe8bfbdd4628fb8fefc730e8c9
parentda50438c3c5c43a235839171e35a1e5044d526fd (diff)
downloadbullet3-2197101bc568a90e7af3bdd49280d4007200aab2.tar.gz
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.)
-rw-r--r--src/Bullet3Serialize/Bullet2FileLoader/b3File.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Bullet3Serialize/Bullet2FileLoader/b3File.cpp b/src/Bullet3Serialize/Bullet2FileLoader/b3File.cpp
index 145de62db..f6c779a91 100644
--- a/src/Bullet3Serialize/Bullet2FileLoader/b3File.cpp
+++ b/src/Bullet3Serialize/Bullet2FileLoader/b3File.cpp
@@ -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);