Avoid NULL pointer dereference.

This commit is contained in:
tsutsui 2001-08-05 11:14:21 +00:00
parent 7810c0591b
commit 9e7c918fc2
1 changed files with 9 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.9 2000/06/01 15:38:26 matt Exp $ */
/* $NetBSD: autoconf.c,v 1.10 2001/08/05 11:14:21 tsutsui Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -84,14 +84,16 @@ findroot()
/*
* Try to find the device where we were booted from.
*/
for (cp = bootpath + strlen(bootpath); --cp >= bootpath;) {
if (*cp == '/') {
*cp = '\0';
if (!dk_match(bootpath)) {
if (bootpath != NULL) {
for (cp = bootpath + strlen(bootpath); --cp >= bootpath;) {
if (*cp == '/') {
*cp = '\0';
if (!dk_match(bootpath)) {
*cp = '/';
break;
}
*cp = '/';
break;
}
*cp = '/';
}
}
dk_cleanup();