From 679591c589db8a29d771bb70a3895796cda9fa1e Mon Sep 17 00:00:00 2001 From: subrata_modak Date: Mon, 19 Jan 2009 09:05:34 +0000 Subject: This patch fixes a segfault of pan, when the command file doesn't end with a newline. Signed-Off-By: Jiri Palecek . --- pan/pan.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'pan') diff --git a/pan/pan.c b/pan/pan.c index bcefb4130..a01ec92c9 100644 --- a/pan/pan.c +++ b/pan/pan.c @@ -49,7 +49,7 @@ * - added option to create a command file with all failed tests. * */ -/* $Id: pan.c,v 1.28 2008/11/11 05:15:52 subrata_modak Exp $ */ +/* $Id: pan.c,v 1.29 2009/01/19 09:05:34 subrata_modak Exp $ */ #include #include @@ -1031,11 +1031,11 @@ get_collection(char *file, int optind, int argc, char **argv) head = p = n = NULL; a = b = buf; - while (*b != '\0') { + while (a) { /* set b to the start of the next line and add a NULL character * to separate the two lines */ if ((b = strchr(a, '\n')) != NULL) - *b = '\0'; + *b++ = '\0'; /* If this is line isn't a comment */ if ((*a != '#') && (*a != '\0') && (*a != ' ')) { @@ -1056,8 +1056,7 @@ get_collection(char *file, int optind, int argc, char **argv) p = n; coll->cnt++; } - a += strlen(a) + 1; - b = a; + a = b; } free(buf); -- cgit v1.2.3