]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/bspfile_abstract.c
Merge commit 'b681f28130ff2e9789253eff1c1d41163e427eaa' into master-merge
[xonotic/netradiant.git] / tools / quake3 / q3map2 / bspfile_abstract.c
index db3a46bb6f0e6ca5a30f26a758408dc5c2cf6547..55d358f0e69b65c9d5aa859bcb5036f12beb3d98 100644 (file)
@@ -68,14 +68,19 @@ void IncDrawVerts(){
 
        }
        else if ( numBSPDrawVerts > numBSPDrawVertsBuffer ) {
+               bspDrawVert_t *newBspDrawVerts;
+
                numBSPDrawVertsBuffer *= 3; // multiply by 1.5
                numBSPDrawVertsBuffer /= 2;
 
-               bspDrawVerts = realloc( bspDrawVerts, sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer );
+               newBspDrawVerts = realloc( bspDrawVerts, sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer );
 
-               if ( !bspDrawVerts ) {
+               if ( !newBspDrawVerts ) {
+                       free (bspDrawVerts);
                        Error( "realloc() failed (IncDrawVerts)" );
                }
+
+               bspDrawVerts = newBspDrawVerts;
        }
 
        memset( bspDrawVerts + ( numBSPDrawVerts - 1 ), 0, sizeof( bspDrawVert_t ) );