summaryrefslogtreecommitdiff
path: root/src/net_server.c
diff options
context:
space:
mode:
authorSimon Howard2014-10-24 20:29:56 -0400
committerSimon Howard2014-10-24 20:29:56 -0400
commit9d01d090c48c74a29b4ef67e0cd204772a2193c3 (patch)
tree3a8dce09c81c6cd9db8adf266d5cc6eae366af98 /src/net_server.c
parentb42b5269e0ad5b22acd6043429ec4013a4e76ddd (diff)
downloadchocolate-doom-9d01d090c48c74a29b4ef67e0cd204772a2193c3.tar.gz
chocolate-doom-9d01d090c48c74a29b4ef67e0cd204772a2193c3.tar.bz2
chocolate-doom-9d01d090c48c74a29b4ef67e0cd204772a2193c3.zip
Replace strdup() with M_StringDuplicate().
strdup() can theoretically fail and return NULL. This could lead to a crash or undesirable behavior. Add M_StringDuplicate() which does the same thing but exits with an error if a string cannot be allocated. This fixes #456. Thanks to Quasar for the suggestion.
Diffstat (limited to 'src/net_server.c')
-rw-r--r--src/net_server.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/net_server.c b/src/net_server.c
index ae8b5897..b4496bb5 100644
--- a/src/net_server.c
+++ b/src/net_server.c
@@ -563,7 +563,7 @@ static void NET_SV_InitNewClient(net_client_t *client,
NET_Conn_InitServer(&client->connection, addr);
client->addr = addr;
client->last_send_time = -1;
- client->name = strdup(player_name);
+ client->name = M_StringDuplicate(player_name);
// init the ticcmd send queue