https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=200402 diff -ru gdb-6.3-orig/bfd/opncls.c gdb-6.3/bfd/opncls.c --- gdb-6.3-orig/bfd/opncls.c 2006-07-28 04:56:05.000000000 -0400 +++ gdb-6.3/bfd/opncls.c 2006-07-28 04:56:25.000000000 -0400 @@ -595,27 +595,36 @@ /* FIXME: cagney/2004-02-15: Need to implement a BFD_IN_MEMORY io vector. */ - if (!(abfd->flags & BFD_IN_MEMORY)) - ret = abfd->iovec->bclose (abfd); - else - ret = TRUE; + if (abfd->flags & BFD_IN_MEMORY) + { + struct bfd_in_memory *bim = abfd->iostream; - /* If the file was open for writing and is now executable, - make it so. */ - if (ret - && abfd->direction == write_direction - && abfd->flags & EXEC_P) + free (bim->buffer); + free (bim); + + ret = TRUE; + } + else { - struct stat buf; + ret = abfd->iovec->bclose (abfd); - if (stat (abfd->filename, &buf) == 0) + /* If the file was open for writing and is now executable, + make it so. */ + if (ret + && abfd->direction == write_direction + && abfd->flags & EXEC_P) { - unsigned int mask = umask (0); + struct stat buf; - umask (mask); - chmod (abfd->filename, - (0777 - & (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask)))); + if (stat (abfd->filename, &buf) == 0) + { + unsigned int mask = umask (0); + + umask (mask); + chmod (abfd->filename, + (0777 + & (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask)))); + } } }