Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/cgdconfig Avoid dereferencing/free()ing invalid pointer...



details:   https://anonhg.NetBSD.org/src/rev/f2508639a64c
branches:  trunk
changeset: 581476:f2508639a64c
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu Jun 02 01:31:30 2005 +0000

description:
Avoid dereferencing/free()ing invalid pointers if the random device
cannot be opened.
Detected with gcc -Wuninitialized.
(The bug was fixed in rev 1.4 by rumble but reintroduced in rev 1.5 by tv !)

diffstat:

 sbin/cgdconfig/utils.c |  9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diffs (31 lines):

diff -r d08fe302df28 -r f2508639a64c sbin/cgdconfig/utils.c
--- a/sbin/cgdconfig/utils.c    Thu Jun 02 01:24:45 2005 +0000
+++ b/sbin/cgdconfig/utils.c    Thu Jun 02 01:31:30 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: utils.c,v 1.7 2005/03/30 17:17:51 elric Exp $ */
+/* $NetBSD: utils.c,v 1.8 2005/06/02 01:31:30 lukem Exp $ */
 
 /*-
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: utils.c,v 1.7 2005/03/30 17:17:51 elric Exp $");
+__RCSID("$NetBSD: utils.c,v 1.8 2005/06/02 01:31:30 lukem Exp $");
 #endif
 
 #include <sys/param.h>
@@ -473,11 +473,8 @@
        FILE    *f;
 
        f = fopen(fn, "r");
-       if (!f) {
-               free(bits->text);
-               free(bits);
+       if (!f)
                return NULL;
-       }
 
        bits = bits_fget(f, len);
        fclose(f);



Home | Main Index | Thread Index | Old Index