summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-11-02 18:19:31 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-11-02 18:19:31 +0000
commit27566edf177012cc7b0e5ae2a155342b3820bd36 (patch)
tree99c910bd11df9d76c0d1c60e2b1a6a9449d62c03
parent745bbe97058998e62c44685f6958ed770d0f8dd4 (diff)
Don't check buf[strlen(buf) - 1] on empty strings.
OK moritz@.
-rw-r--r--games/quiz/quiz.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/games/quiz/quiz.c b/games/quiz/quiz.c
index 665e93bc59b..13bac941945 100644
--- a/games/quiz/quiz.c
+++ b/games/quiz/quiz.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: quiz.c,v 1.16 2004/07/10 07:26:23 deraadt Exp $ */
+/* $OpenBSD: quiz.c,v 1.17 2006/11/02 18:19:30 ray Exp $ */
/* $NetBSD: quiz.c,v 1.9 1995/04/22 10:16:58 cgd Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)quiz.c 8.3 (Berkeley) 5/4/95";
#else
-static char rcsid[] = "$OpenBSD: quiz.c,v 1.16 2004/07/10 07:26:23 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: quiz.c,v 1.17 2006/11/02 18:19:30 ray Exp $";
#endif
#endif /* not lint */
@@ -133,7 +133,8 @@ get_file(const char *file)
while ((lp = fgetln(fp, &len)) != NULL) {
if (lp[len - 1] == '\n')
--len;
- if (qp->q_text && qp->q_text[strlen(qp->q_text) - 1] == '\\')
+ if (qp->q_text && qp->q_text[0] != '\0' &&
+ qp->q_text[strlen(qp->q_text) - 1] == '\\')
qp->q_text = appdstr(qp->q_text, lp, len);
else {
if ((qp->q_next = malloc(sizeof(QE))) == NULL)