Browse Source

engine: fix uninitialized variable in demo parsing code, fix incorrect size counter in memory allocator

pull/2/head
Valery Klachkov 2 years ago committed by GitHub
parent
commit
3ad60a0fa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      engine/client/cl_demo.c
  2. 6
      engine/common/zone.c

2
engine/client/cl_demo.c

@ -888,7 +888,7 @@ qboolean CL_DemoReadMessage( byte *buffer, size_t *length ) @@ -888,7 +888,7 @@ qboolean CL_DemoReadMessage( byte *buffer, size_t *length )
qboolean swallowmessages = true;
static int tdlastdemoframe = 0;
byte *userbuf = NULL;
size_t size;
size_t size = 0;
byte cmd;
if( !cls.demofile )

6
engine/common/zone.c

@ -91,8 +91,8 @@ void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char @@ -91,8 +91,8 @@ void *_Mem_Alloc( poolhandle_t poolptr, size_t size, qboolean clear, const char
pool->totalsize += size;
// big allocations are not clumped
pool->realsize += sizeof( memheader_t ) + size + sizeof( int );
mem = (memheader_t *)Q_malloc( sizeof( memheader_t ) + size + sizeof( int ));
pool->realsize += sizeof( memheader_t ) + size + sizeof( size_t );
mem = (memheader_t *)Q_malloc( sizeof( memheader_t ) + size + sizeof( size_t ));
if( mem == NULL ) Sys_Error( "Mem_Alloc: out of memory (alloc at %s:%i)\n", filename, fileline );
mem->filename = filename;
@ -162,7 +162,7 @@ static void Mem_FreeBlock( memheader_t *mem, const char *filename, int fileline @@ -162,7 +162,7 @@ static void Mem_FreeBlock( memheader_t *mem, const char *filename, int fileline
// memheader has been unlinked, do the actual free now
pool->totalsize -= mem->size;
pool->realsize -= sizeof( memheader_t ) + mem->size + sizeof( int );
pool->realsize -= sizeof( memheader_t ) + mem->size + sizeof( size_t );
Q_free( mem );
}

Loading…
Cancel
Save