gdb/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 23 Jan 2012 16:37:03 +0000 (16:37 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 23 Jan 2012 16:37:03 +0000 (16:37 +0000)
* cli/cli-cmds.c (find_and_open_script): Handle failure of fdopen.

gdb/ChangeLog
gdb/cli/cli-cmds.c

index 932c035fb99d43e21a60b25d28868803debba187..b73d98f694bb3c6e908220048086e013211660ce 100644 (file)
@@ -1,3 +1,7 @@
+2012-01-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * cli/cli-cmds.c (find_and_open_script): Handle failure of fdopen.
+
 2012-01-23  Ulrich Weigand  <ulrich.weigand@linaro.org>
 
        * inf-child.c: Include "gdb_stat.h" instead of <sys/stat.h>.
index c38167a17594b8ad5e6fe56c8182a6238ffac8a1..91421aa067b4ef0cc028da897629568cf688f97f 100644 (file)
@@ -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;
+
+      close (fd);
+      if (full_pathp)
+       xfree (*full_pathp);
+      errno = save_errno;
+      return 0;
+    }
+
   return 1;
 }