From 6c0af71bdc3a235c403c459c01146c818cb95e1a Mon Sep 17 00:00:00 2001 From: Xin LI Date: Mon, 23 Mar 2009 23:43:07 +0000 Subject: [PATCH] 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(-) diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c index fb7333ea101..393358f2ff9 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); }