[SV 63315] Allocate function names when defining functions

* 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.
This commit is contained in:
Paul Smith 2022-11-05 12:56:52 -04:00
parent d71c0bb0ce
commit e80ce6fc90

View 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;