Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/ifconfig Avoid dereferencing NULL. Coverity CID 275201.
details: https://anonhg.NetBSD.org/src/rev/69cbde41dfcc
branches: trunk
changeset: 784718:69cbde41dfcc
user: apb <apb%NetBSD.org@localhost>
date: Thu Feb 07 13:20:51 2013 +0000
description:
Avoid dereferencing NULL. Coverity CID 275201.
Also fix a typo in previous: !== should be !=
diffstat:
sbin/ifconfig/env.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diffs (44 lines):
diff -r 5deaefcb1198 -r 69cbde41dfcc sbin/ifconfig/env.c
--- a/sbin/ifconfig/env.c Thu Feb 07 12:04:01 2013 +0000
+++ b/sbin/ifconfig/env.c Thu Feb 07 13:20:51 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: env.c,v 1.8 2013/02/07 11:24:15 apb Exp $ */
+/* $NetBSD: env.c,v 1.9 2013/02/07 13:20:51 apb Exp $ */
/*-
* Copyright (c) 2008 David Young. All rights reserved.
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: env.c,v 1.8 2013/02/07 11:24:15 apb Exp $");
+__RCSID("$NetBSD: env.c,v 1.9 2013/02/07 13:20:51 apb Exp $");
#endif /* not lint */
#include <errno.h>
@@ -53,10 +53,12 @@
const char *key;
d = prop_dictionary_copy_mutable(bottom);
+ if (d == NULL)
+ return NULL;
i = prop_dictionary_iterator(top);
- while ((ko = prop_object_iterator_next(i)) != NULL) {
+ while (i != NULL && (ko = prop_object_iterator_next(i)) != NULL) {
k = (prop_dictionary_keysym_t)ko;
key = prop_dictionary_keysym_cstring_nocopy(k);
o = prop_dictionary_get_keysym(top, k);
@@ -66,8 +68,9 @@
break;
}
}
- prop_object_iterator_release(i);
- if (d !== NULL)
+ if (i != NULL)
+ prop_object_iterator_release(i);
+ if (d != NULL)
prop_dictionary_make_immutable(d);
return d;
}
Home |
Main Index |
Thread Index |
Old Index