summaryrefslogtreecommitdiffstats
path: root/games
diff options
context:
space:
mode:
Diffstat (limited to 'games')
-rw-r--r--games/quiz/quiz.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/games/quiz/quiz.c b/games/quiz/quiz.c
index aa5f527..25ee3ed 100644
--- a/games/quiz/quiz.c
+++ b/games/quiz/quiz.c
@@ -316,11 +316,14 @@ appdstr(s, tp, len)
if ((m = malloc(strlen(s) + len + 1)) == NULL)
err("%s", strerror(errno));
for (mp = m, sp = s; *mp++ = *sp++;);
+ mp--;
if (*(mp - 1) == '\\')
--mp;
- while ((ch = *mp++ = *tp++) && ch != '\n');
- *mp = '\0';
+ memcpy(mp, tp, len);
+ mp[len] = '\0';
+ if (mp[len - 1] == '\n')
+ mp[len - 1] = '\0';
free(s);
return (m);
OpenPOWER on IntegriCloud