1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-07-07 15:54:14 -04:00

Bug fix: actually copy the string read in to the destination buffer

This commit is contained in:
John Zaitseff 2011-07-13 12:51:25 +10:00
parent 3f96e587aa
commit 0b9b60780d

View File

@ -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; \
}