From 28bb88e9b43a2270c96dea643377e0e1ebae0278 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 6 Mar 2024 04:39:29 +0100 Subject: [PATCH] Dynamically allocate space for a state's action field https://git.do.srb2.org/STJr/SRB2/-/merge_requests/1478 --- src/dehacked.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 8c1ba8e4d..63e240a06 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1716,13 +1716,13 @@ static void readframe(MYFILE *f, INT32 num) { size_t z; boolean found = false; - char actiontocompare[32]; + size_t actionlen = strlen(word2) + 1; + char *actiontocompare = calloc(actionlen, 1); - memset(actiontocompare, 0x00, sizeof(actiontocompare)); - strlcpy(actiontocompare, word2, sizeof (actiontocompare)); + strcpy(actiontocompare, word2); strupr(actiontocompare); - for (z = 0; z < 32; z++) + for (z = 0; z < actionlen; z++) { if (actiontocompare[z] == '\n' || actiontocompare[z] == '\r') { @@ -1758,6 +1758,8 @@ static void readframe(MYFILE *f, INT32 num) if (!found) deh_warning("Unknown action %s", actiontocompare); + + free(actiontocompare); } else deh_warning("Frame %d: unknown word '%s'", num, word1);