diff options
author | Simon Howard | 2014-10-24 20:29:56 -0400 |
---|---|---|
committer | Simon Howard | 2014-10-24 20:29:56 -0400 |
commit | 9d01d090c48c74a29b4ef67e0cd204772a2193c3 (patch) | |
tree | 3a8dce09c81c6cd9db8adf266d5cc6eae366af98 /src/gusconf.c | |
parent | b42b5269e0ad5b22acd6043429ec4013a4e76ddd (diff) | |
download | chocolate-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/gusconf.c')
-rw-r--r-- | src/gusconf.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gusconf.c b/src/gusconf.c index 70cdd87c..a2dfdac3 100644 --- a/src/gusconf.c +++ b/src/gusconf.c @@ -26,6 +26,7 @@ #include <string.h> #include <ctype.h> +#include "m_misc.h" #include "w_wad.h" #include "z_zone.h" @@ -122,7 +123,7 @@ static void ParseLine(gus_config_t *config, char *line) mapped_id = atoi(fields[MappingIndex()]); free(config->patch_names[instr_id]); - config->patch_names[instr_id] = strdup(fields[5]); + config->patch_names[instr_id] = M_StringDuplicate(fields[5]); config->mapping[instr_id] = mapped_id; } |