From 5914e16076339ef487094dba8be67eed21b0a811 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 18 Oct 2014 20:33:30 -0400 Subject: dehacked: Allow override of string replacements. If loading two dehacked patches and both replace the same string, the second replacement should override the first. Change the API function DEH_AddStringReplacement so that the from_text and to_text are implicitly duplicated, and we can free to_text and replace it later if we subsequently change it to something else. --- src/heretic/deh_htext.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/heretic') diff --git a/src/heretic/deh_htext.c b/src/heretic/deh_htext.c index 55f32872..fe0dc663 100644 --- a/src/heretic/deh_htext.c +++ b/src/heretic/deh_htext.c @@ -16,6 +16,7 @@ // #include +#include #include #include "doomtype.h" @@ -776,7 +777,7 @@ static void *DEH_TextStart(deh_context_t *context, char *line) return NULL; } - repl_text = Z_Malloc(repl_len + 1, PU_STATIC, NULL); + repl_text = malloc(repl_len + 1); // read in the "to" text @@ -819,13 +820,10 @@ static void *DEH_TextStart(deh_context_t *context, char *line) // Success. DEH_AddStringReplacement(orig_text, repl_text); - - return NULL; } - // Failure. - - Z_Free(repl_text); + // We must always free the replacement text. + free(repl_text); return NULL; } -- cgit v1.2.3