Save the variable buffer content, not a potentially old pointer to it.
authorPaul Smith <psmith@gnu.org>
Sun, 9 Sep 2012 21:56:55 +0000 (21:56 +0000)
committerPaul Smith <psmith@gnu.org>
Sun, 9 Sep 2012 21:56:55 +0000 (21:56 +0000)
Fixes Savannah bug #36925.

ChangeLog
file.c

index 261be30920e2118db07018164fd59a62c4675ea4..943552eec884fbd56e422ada735882557634a6bf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2012-09-09  Paul Smith  <psmith@gnu.org>
 
+       * file.c (expand_deps): Duplicate the current variable buffer, not
+       the old pointer.  Fixes Savannah bug #36925.
+
        * read.c (eval): If we detect an initial UTF-8 BOM, skip it.
        Fixes Savannah bug #36529.
        (record_target_var): Remove unused variable "fname".
diff --git a/file.c b/file.c
index 21582e002ecce13764c8bde5b7a13238768aaad4..896f7e223059902f82dae19d9fce42bfa5415cfa 100644 (file)
--- a/file.c
+++ b/file.c
@@ -573,12 +573,11 @@ expand_deps (struct file *f)
          "$*" so they'll expand properly.  */
       if (d->staticpattern)
         {
-          char *o;
-          d->name = o = variable_expand ("");
+          char *o = variable_expand ("");
           o = subst_expand (o, name, "%", "$*", 1, 2, 0);
           *o = '\0';
           free (name);
-          d->name = name = xstrdup (d->name);
+          d->name = name = xstrdup (variable_buffer);
           d->staticpattern = 0;
         }