From 78c7bc43defdc06fa3a85bdd27b7048a88f938f4 Mon Sep 17 00:00:00 2001 From: delphij Date: Mon, 23 Mar 2009 23:43:07 +0000 Subject: Save errno before calling _close(), which may clear it. Obtained from: OpenBSD --- lib/libc/db/btree/bt_open.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/libc/db/btree/bt_open.c') diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c index fb7333e..393358f 100644 --- a/lib/libc/db/btree/bt_open.c +++ b/lib/libc/db/btree/bt_open.c @@ -96,7 +96,7 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int DB *dbp; pgno_t ncache; ssize_t nr; - int machine_lorder; + int machine_lorder, saved_errno; t = NULL; @@ -327,13 +327,15 @@ einval: errno = EINVAL; eftype: errno = EFTYPE; goto err; -err: if (t) { +err: saved_errno = errno; + if (t) { if (t->bt_dbp) free(t->bt_dbp); if (t->bt_fd != -1) (void)_close(t->bt_fd); free(t); } + errno = saved_errno; return (NULL); } -- cgit v1.1