Skip to content

Commit

Permalink
Zero pointers after free. Better "net info" for the server. Client mu…
Browse files Browse the repository at this point in the history
…st not spawn a player if not in a level; avoids crashing.

Debug assertions.
  • Loading branch information
skyjake committed Jan 8, 2007
1 parent 4a27629 commit 1302413
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions doomsday/engine/portable/src/dd_zone.c
Expand Up @@ -786,6 +786,8 @@ static void Z_AddBlockToSet(zblockset_t* set)
block->max = set->elementsPerBlock;
block->elementSize = set->elementSize;
block->elements = Z_Malloc(block->elementSize * block->max, set->tag, NULL);

assert(block->count == 0);
}

/**
Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/portable/src/net_main.c
Expand Up @@ -603,6 +603,7 @@ void Net_StopGame(void)
{
players[i].ingame = false;
clients[i].ready = clients[i].connected = false;
clients[i].nodeID = 0;
players[i].flags &= ~(DDPF_CAMERA | DDPF_CHASECAM | DDPF_LOCAL);
}

Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/sv_main.c
Expand Up @@ -363,7 +363,7 @@ void Sv_HandlePacket(void)
// Send a message to everybody.
Con_FPrintf(CBLF_TRANSMIT | SV_CONSOLE_FLAGS,
"New client connection refused: Duplicate ID "
"(%08x).\n", id);
"(%08x). From=%i, i=%i\n", id, from, i);
N_TerminateClient(from);
break;
}
Expand Down
5 changes: 4 additions & 1 deletion doomsday/plugins/common/src/g_game.c
Expand Up @@ -1263,7 +1263,10 @@ void G_DoReborn(int playernum)

if(IS_CLIENT)
{
G_DummySpawnPlayer(playernum);
if(gamestate == GS_LEVEL)
{
G_DummySpawnPlayer(playernum);
}
return;
}

Expand Down
8 changes: 7 additions & 1 deletion doomsday/plugins/common/src/hu_msg.c
Expand Up @@ -403,7 +403,10 @@ void HUMsg_PlayerMessage(player_t *plr, char *message, int tics,
if(!msgBuff->nottobefuckedwith || msgBuff->dontfuckwithme)
{
if(msgBuff->lastmessage)
{
free(msgBuff->lastmessage);
msgBuff->lastmessage = NULL;
}

if(yellow)
{
Expand Down Expand Up @@ -459,7 +462,7 @@ static void HU_MsgBufAddMessage(msgbuffer_t *buf, char *txt, int tics)
msg = &buf->messages[buf->lastmsg];

len = strlen(txt);
msg->text = realloc(msg->text, len+ 1);
msg->text = realloc(msg->text, len + 1);
strcpy(msg->text, txt);
msg->text[len] = 0;
msg->time = msg->duration = cfg.msgUptime + tics;
Expand Down Expand Up @@ -510,7 +513,10 @@ static void HU_MsgBufClear(msgbuffer_t *buf)
for(i = 0; i < MAX_MESSAGES; ++i)
{
if(buf->messages[i].text)
{
free(buf->messages[i].text);
buf->messages[i].text = NULL;
}
}

buf->firstmsg = buf->lastmsg = 0;
Expand Down

0 comments on commit 1302413

Please sign in to comment.