From 0b9b60780db8b9187e1dbd07dade6d193f946e53 Mon Sep 17 00:00:00 2001 From: John Zaitseff Date: Wed, 13 Jul 2011 12:51:25 +1000 Subject: [PATCH] Bug fix: actually copy the string read in to the destination buffer --- src/game.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/game.c b/src/game.c index b54131f..c6c990d 100644 --- a/src/game.c +++ b/src/game.c @@ -73,6 +73,7 @@ #define load_game_read_string(_var) \ { \ char *s; \ + int len; \ \ if (fgets(buf, GAME_BUFSIZE, file) == NULL) { \ err_exit("%s: missing field on line %d", filename, lineno); \ @@ -86,6 +87,13 @@ if (s == NULL) { \ err_exit("out of memory"); \ } \ + \ + strcpy(s, buf); \ + len = strlen(s); \ + if ((len > 0) && (s[len - 1] == '\n')) { \ + s[len - 1] = '\0'; \ + } \ + \ (_var) = s; \ }