Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2931)

Unified Diff: bfd/opncls.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bfd/oasys.c ('k') | bfd/osf-core.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bfd/opncls.c
diff --git a/bfd/opncls.c b/bfd/opncls.c
index 9d33f3974fb0b3f214a14272463092f0a61e9860..7c1d2f99a5815990d97da36958079a91e8538946 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -1,6 +1,6 @@
/* opncls.c -- open and close a BFD.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012
Free Software Foundation, Inc.
Written by Cygnus Support.
@@ -190,6 +190,8 @@ DESCRIPTION
If <<NULL>> is returned then an error has occured. Possible errors
are <<bfd_error_no_memory>>, <<bfd_error_invalid_target>> or
<<system_call>> error.
+
+ On error, @var{fd} is always closed.
*/
bfd *
@@ -200,11 +202,17 @@ bfd_fopen (const char *filename, const char *target, const char *mode, int fd)
nbfd = _bfd_new_bfd ();
if (nbfd == NULL)
- return NULL;
+ {
+ if (fd != -1)
+ close (fd);
+ return NULL;
+ }
target_vec = bfd_find_target (target, nbfd);
if (target_vec == NULL)
{
+ if (fd != -1)
+ close (fd);
_bfd_delete_bfd (nbfd);
return NULL;
}
@@ -307,6 +315,8 @@ DESCRIPTION
Possible errors are <<bfd_error_no_memory>>,
<<bfd_error_invalid_target>> and <<bfd_error_system_call>>.
+
+ On error, @var{fd} is closed.
*/
bfd *
@@ -323,6 +333,10 @@ bfd_fdopenr (const char *filename, const char *target, int fd)
fdflags = fcntl (fd, F_GETFL, NULL);
if (fdflags == -1)
{
+ int save = errno;
+
+ close (fd);
+ errno = save;
bfd_set_error (bfd_error_system_call);
return NULL;
}
« no previous file with comments | « bfd/oasys.c ('k') | bfd/osf-core.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698