check hashp before closing the file descriptor on error
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 27 Sep 1991 06:27:32 +0000 (22:27 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Fri, 27 Sep 1991 06:27:32 +0000 (22:27 -0800)
SCCS-vsn: lib/libc/db/hash/hash.c 5.19

usr/src/lib/libc/db/hash/hash.c

index fa6043e..18201a4 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash.c     5.18 (Berkeley) %G%";
+static char sccsid[] = "@(#)hash.c     5.19 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
@@ -199,7 +199,8 @@ __hash_open(file, flags, mode, info)
        return (dbp);
 
 error1:
        return (dbp);
 
 error1:
-       (void)close(hashp->fp);
+       if (hashp != NULL)
+               (void)close(hashp->fp);
 
 error0:
        free(hashp);
 
 error0:
        free(hashp);