Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Mar 2009 23:43:07 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r190344 - head/lib/libc/db/btree
Message-ID:  <200903232343.n2NNh7LE025076@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Mon Mar 23 23:43:07 2009
New Revision: 190344
URL: http://svn.freebsd.org/changeset/base/190344

Log:
  Save errno before calling _close(), which may clear it.
  
  Obtained from:	OpenBSD

Modified:
  head/lib/libc/db/btree/bt_open.c

Modified: head/lib/libc/db/btree/bt_open.c
==============================================================================
--- head/lib/libc/db/btree/bt_open.c	Mon Mar 23 23:32:20 2009	(r190343)
+++ head/lib/libc/db/btree/bt_open.c	Mon Mar 23 23:43:07 2009	(r190344)
@@ -96,7 +96,7 @@ __bt_open(const char *fname, int flags, 
 	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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903232343.n2NNh7LE025076>