Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/db/recno Ensure dbp is initialized to NULL before t...



details:   https://anonhg.NetBSD.org/src/rev/cb53ef3974ef
branches:  trunk
changeset: 581377:cb53ef3974ef
user:      lukem <lukem%NetBSD.org@localhost>
date:      Wed Jun 01 05:39:17 2005 +0000

description:
Ensure dbp is initialized to NULL before trying to use it in an error codepath.
Detected with gcc -Wuninitialized.
(The bug was introduced in rev 1.13.  Hi Mycroft! :)

diffstat:

 lib/libc/db/recno/rec_open.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r f5f7c7e90ec0 -r cb53ef3974ef lib/libc/db/recno/rec_open.c
--- a/lib/libc/db/recno/rec_open.c      Wed Jun 01 05:30:54 2005 +0000
+++ b/lib/libc/db/recno/rec_open.c      Wed Jun 01 05:39:17 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rec_open.c,v 1.13 2005/01/19 00:23:44 mycroft Exp $    */
+/*     $NetBSD: rec_open.c,v 1.14 2005/06/01 05:39:17 lukem Exp $      */
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)rec_open.c 8.10 (Berkeley) 9/1/94";
 #else
-__RCSID("$NetBSD: rec_open.c,v 1.13 2005/01/19 00:23:44 mycroft Exp $");
+__RCSID("$NetBSD: rec_open.c,v 1.14 2005/06/01 05:39:17 lukem Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -72,6 +72,7 @@
        int rfd = -1;   /* pacify gcc */
        int sverrno;
 
+       dbp = NULL;
        /* Open the user's file -- if this fails, we're done. */
        if (fname != NULL) {
                if ((rfd = open(fname, flags, mode)) == -1)
@@ -81,7 +82,6 @@
        }
 
        /* Create a btree in memory (backed by disk). */
-       dbp = NULL;
        if (openinfo) {
                if (openinfo->flags & ~(R_FIXEDLEN | R_NOKEY | R_SNAPSHOT))
                        goto einval;



Home | Main Index | Thread Index | Old Index