summaryrefslogtreecommitdiff
path: root/sys/lib
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-01-18 21:46:51 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-01-18 21:46:51 +0000
commitff44168705fb040fffdf010b3719aa3a86316cda (patch)
treedcb62752f8e5315f5825f69d225cde9b9443e251 /sys/lib
parentcd4c10670c4f95362f946ee0b2edeaeb66d9d5cb (diff)
If open() failed because the file does not exist, a struct sd for this file
won't be allocated. Check for this in close() so as not to free() bogus pointers.
Diffstat (limited to 'sys/lib')
-rw-r--r--sys/lib/libsa/cread.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/lib/libsa/cread.c b/sys/lib/libsa/cread.c
index a1445bed320..e8a9c63856f 100644
--- a/sys/lib/libsa/cread.c
+++ b/sys/lib/libsa/cread.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cread.c,v 1.12 2004/04/02 04:39:51 deraadt Exp $ */
+/* $OpenBSD: cread.c,v 1.13 2009/01/18 21:46:50 miod Exp $ */
/* $NetBSD: cread.c,v 1.2 1997/02/04 18:38:20 thorpej Exp $ */
/*
@@ -250,11 +250,12 @@ close(int fd)
return(oclose(fd));
s = ss[fd];
+ if (s != NULL) {
+ inflateEnd(&(s->stream));
- inflateEnd(&(s->stream));
-
- free(s->inbuf, Z_BUFSIZE);
- free(s, sizeof(struct sd));
+ free(s->inbuf, Z_BUFSIZE);
+ free(s, sizeof(struct sd));
+ }
return(oclose(fd));
}