[patch] find_and_open_script: Fix failed fdopen
Jan Kratochvil
jan.kratochvil@redhat.com
Mon Jan 23 16:09:00 GMT 2012
Hi,
just noticed if fdopen fails find_and_open_script returns generally invalid
result. I just read the code, not seen in practice.
No regressions on {x86_64,x86_64-m32,i686}-fedorarawhide-linux-gnu.
I will check it in.
Thanks,
Jan
gdb/
2012-01-23 Jan Kratochvil <jan.kratochvil@redhat.com>
* cli/cli-cmds.c (find_and_open_script): Handle failure of fdopen.
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -513,6 +513,17 @@ find_and_open_script (const char *script_file, int search_path,
do_cleanups (old_cleanups);
*streamp = fdopen (fd, FOPEN_RT);
+ if (*streamp == NULL)
+ {
+ int save_errno = errno;
+
+ if (full_pathp)
+ xfree (*full_pathp);
+ do_cleanups (old_cleanups);
+ errno = save_errno;
+ return 0;
+ }
+
return 1;
}
More information about the Gdb-patches
mailing list