Module Name:    src
Committed By:   martin
Date:           Thu May 16 19:19:44 UTC 2013

Modified Files:
        src/external/bsd/pkg_install/dist/lib: var.c

Log Message:
var_get_memory():
if no eol is found in the string we set "next" to NULL, assign it
to "buf" and then check the loop condition by dereferencing it - which
does not work well.
Change the loop condition to first check for buf == NULL.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3 -r1.2 src/external/bsd/pkg_install/dist/lib/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/pkg_install/dist/lib/var.c
diff -u src/external/bsd/pkg_install/dist/lib/var.c:1.1.1.3 src/external/bsd/pkg_install/dist/lib/var.c:1.2
--- src/external/bsd/pkg_install/dist/lib/var.c:1.1.1.3	Thu Aug  6 16:55:29 2009
+++ src/external/bsd/pkg_install/dist/lib/var.c	Thu May 16 19:19:44 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1.1.3 2009/08/06 16:55:29 joerg Exp $	*/
+/*	$NetBSD: var.c,v 1.2 2013/05/16 19:19:44 martin Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #if HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
-__RCSID("$NetBSD: var.c,v 1.1.1.3 2009/08/06 16:55:29 joerg Exp $");
+__RCSID("$NetBSD: var.c,v 1.2 2013/05/16 19:19:44 martin Exp $");
 
 #if HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -156,7 +156,7 @@ var_get_memory(const char *buf, const ch
 	value = NULL;
 	valuelen = 0;
 
-	for (; *buf; buf = next) {
+	for (; buf && *buf; buf = next) {
 		if ((eol = strchr(buf, '\n')) != NULL) {
 			next = eol + 1;
 			len = eol - buf;

Reply via email to