summaryrefslogtreecommitdiff
path: root/source/common.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2007-09-22 18:44:50 +0000
committerAndrey Nazarov <skuller@skuller.net>2007-09-22 18:44:50 +0000
commit8cb1f3121ea0120217d28d48221e9bf6529d073c (patch)
tree97584c3623890d16cd169f41fa04450f36ba97b3 /source/common.c
parent36432ed920ff260f4904aab1fa816b2f34c592b4 (diff)
Fixed nasty bug instroduced by packetized sound message handling due to
uninitialized memory access. Server crashed randomly when someone disconnected. Added z_perturb cvar to help debug and prevent such problems.
Diffstat (limited to 'source/common.c')
-rw-r--r--source/common.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/source/common.c b/source/common.c
index afe079f..0d632e9 100644
--- a/source/common.c
+++ b/source/common.c
@@ -505,6 +505,8 @@ typedef struct zhead_s {
static zhead_t z_chain;
+static cvar_t *z_perturb;
+
typedef struct zstatic_s {
zhead_t z;
char data[2]; /* !!make sure 'tail' field is aligned properly */
@@ -772,6 +774,11 @@ void *Z_TagMalloc( size_t size, memtag_t tag ) {
z_chain.next->prev = z;
z_chain.next = z;
+ if( z_perturb && z_perturb->integer ) {
+ memset( z + 1, z_perturb->integer, size -
+ sizeof( zhead_t ) - sizeof( uint16 ) );
+ }
+
*( uint16 * )( ( byte * )z + size - sizeof( uint16 ) ) = Z_TAIL;
s = &z_stats[tag < TAG_MAX ? tag : TAG_FREE];
@@ -1385,6 +1392,7 @@ void Qcommon_Init( char *commandLine ) {
//
// init commands and vars
//
+ z_perturb = Cvar_Get( "z_perturb", "0", 0 );
host_speeds = Cvar_Get ("host_speeds", "0", 0);
developer = Cvar_Get ("developer", "0", 0);
timescale = Cvar_Get ("timescale", "1", CVAR_CHEAT );