From 50ca48629c761ddb53df59092bc39d3a799b7e37 Mon Sep 17 00:00:00 2001
From: Etienne Brateau <etienne.brateau@ensiie.fr>
Date: Tue, 5 Feb 2019 23:01:02 +0100
Subject: [PATCH] Remove use of realloc in goodfixname.

It's because all strings are char[256] and not on the heap. And more,
the reallocation was a broken thing because the pointer was not
correctly updated (need return char* or parameter change).

Fix crash when saving and was introduced in d0dbd3e28139242a77cd93b7b32ad1cd5f0265c7
---
 src/graphics/newci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/graphics/newci.c b/src/graphics/newci.c
index 33ae09f..02db92f 100644
--- a/src/graphics/newci.c
+++ b/src/graphics/newci.c
@@ -89,7 +89,9 @@ static void goodfixname(char *name, char *ext, char *home, int force)
 
 	if (!hassuffix && *ext != '\0')
 	{
-		name = realloc(name, sizeof(char) * (len + strlen(ext) + 2)); /* name + '.' + ext + '\0' */
+		/* Disabling reallocation because all strings are char[256], will change in future */
+		/* Warning: when doing reallocation, return char* or take char** because of reallocation */
+		//name = realloc(name, sizeof(char) * (len + strlen(ext) + 2)); /* name + '.' + ext + '\0' */
 		sprintf(name + strlen(name), ".%s", ext);
 	}
 }
-- 
GitLab