forked from fte/fteqw
1
0
Fork 0

Merge pull request #180 from fhomolka/plug_bullet_build_fix

[Minor] Fix plugin.c failing when building Bullet Plugin
This commit is contained in:
Marco Cawthorne 2023-06-02 09:31:31 -07:00 committed by GitHub
commit 7604e8e655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -264,19 +264,31 @@ qboolean ZF_ReallocElements(void **ptr, size_t *elements, size_t newelements, si
//protect against malicious overflows
if (newelements > SIZE_MAX / elementsize)
#ifdef __cplusplus
return qfalse;
#else
return false;
#endif
oldsize = *elements * elementsize;
newsize = newelements * elementsize;
n = plugfuncs->Realloc(*ptr, newsize);
if (!n)
#ifdef __cplusplus
return qfalse;
#else
return false;
#endif
if (newsize > oldsize)
memset((char*)n+oldsize, 0, newsize - oldsize);
*elements = newelements;
*ptr = n;
return true;
#ifdef __cplusplus
return qtrue;
#else
return true;
#endif
}