macro: Fix memory leak with keyword "enclose" arguments.
[pspp] / src / language / lexer / macro.c
index 742b8771ac8d353ed113cf97367ce59ff59da10c..62d060aad2ce21bc6320c0f05960f46051993cd4 100644 (file)
@@ -707,7 +707,8 @@ mc_enclose (struct macro_call *mc, const struct macro_token *mt,
       mc->n_tokens++;
 
       struct macro_tokens **argp = &mc->args[p - mc->macro->params];
-      *argp = xzalloc (sizeof **argp);
+      if (!*argp)
+        *argp = xzalloc (sizeof **argp);
       mc->state = MC_ARG;
       return 0;
     }
@@ -1038,7 +1039,8 @@ unquote_string (const char *s, enum segmenter_mode segmenter_mode,
       return false;
     }
 
-  ds_put_substring (content, token1.string);
+  if (content)
+    ds_put_substring (content, token1.string);
   token_uninit (&token1);
   return true;
 }