A rather obvious fix; the memory is freed by the caller (gfc_simplify_compiler_options). It is unlikely that the compiler has no arguments as the driver tends to send some, e.g. "-mtune=generic -march=x86-64" on my system. However, it is better to be safe than sorry.

Build and regtested on x86-64-gnu-linux.
OK?

Tobias
2013-10-09  Tobias Burnus  <bur...@net-b.de>

	PR fortran/58226
	* options.c (gfc_get_option_string): Handle zero arg case.

diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 3a9c508..6e4e7c1 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -1166,6 +1166,10 @@ gfc_get_option_string (void)
   size_t len, pos;
   char *result;
 
+  /* Allocate and return a one-character string with '\0'.  */
+  if (!save_decoded_options_count)
+    return XCNEWVEC (char, 1);
+
   /* Determine required string length.  */
 
   len = 0;

Reply via email to