]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 63315] Allocate function names when defining functions
authorPaul Smith <psmith@gnu.org>
Sat, 5 Nov 2022 16:56:52 +0000 (12:56 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 13 Nov 2022 15:39:48 +0000 (10:39 -0500)
* src/function.c (define_new_function): Don't keep a pointer to the
user-provided name of a user-defined function: if the .so is unloaded
it will point to garbage.  Add the name to the strcache instead.

src/function.c

index f0ef34348d6141a3a97691467a74090845d7f6a0..e4a3af86f3e1daa4afaa6af6517915231bb59d84 100644 (file)
@@ -2801,7 +2801,7 @@ define_new_function (const floc *flocp, const char *name,
          _("Invalid maximum argument count (%u) for function %s"), max, name);
 
   ent = xmalloc (sizeof (struct function_table_entry));
-  ent->name = name;
+  ent->name = strcache_add (name);
   ent->len = (unsigned char) len;
   ent->minimum_args = (unsigned char) min;
   ent->maximum_args = (unsigned char) max;