summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sim/common/ChangeLog6
-rw-r--r--sim/common/sim-options.c10
2 files changed, 13 insertions, 3 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index b6805db5e2c..821248d1230 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-27 Mike Frysinger <vapier@gentoo.org>
+
+ * sim-options.c (standard_option_handler): Remove arg[0] check
+ when freeing simulator_sysroot. Only strdup arg when arg[0] is
+ not an empty string, otherwise assign "" back to it.
+
2011-05-26 Mike Frysinger <vapier@gentoo.org>
* nltvals.def: Regenerate to include Blackfin syscalls again.
diff --git a/sim/common/sim-options.c b/sim/common/sim-options.c
index ddab83dbee2..1a0c541249b 100644
--- a/sim/common/sim-options.c
+++ b/sim/common/sim-options.c
@@ -458,10 +458,14 @@ standard_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
case OPTION_SYSROOT:
/* Don't leak memory in the odd event that there's lots of
- --sysroot=... options. */
- if (simulator_sysroot[0] != '\0' && arg[0] != '\0')
+ --sysroot=... options. We treat "" specially since this
+ is the statically initialized value and cannot free it. */
+ if (simulator_sysroot[0] != '\0')
free (simulator_sysroot);
- simulator_sysroot = xstrdup (arg);
+ if (arg[0] != '\0')
+ simulator_sysroot = xstrdup (arg);
+ else
+ simulator_sysroot = "";
break;
}