diff options
| author | Hauke Mehrtens | 2026-05-03 20:52:57 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2026-05-03 23:59:58 +0000 |
| commit | 0df62571f158f26cda43865df00ef59253a9a8fd (patch) | |
| tree | 90973493edbfed2be0b42c0de2b1cb2710067168 | |
| parent | 81527e1f763092688bb10deed0f123f502caf926 (diff) | |
| download | uhttpd-0df62571f158f26cda43865df00ef59253a9a8fd.tar.gz | |
ucode: initialize module search path only once
uh_ucode_state_init is invoked once per configured ucode prefix
from ucode_plugin_init. The search path lives in the file-static
'config' struct, and uc_search_path_init() appends the default
paths to that struct's vector each time it is called. Running it
per prefix therefore accumulates duplicate entries in the module
search path (and leaks the duplicate strdup'd strings) once more
than one ucode handler is configured.
Hoist the call to ucode_plugin_init so the default search path is
populated exactly once before any VMs are initialized.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
| -rw-r--r-- | ucode.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -231,7 +231,6 @@ uh_ucode_state_init(struct ucode_prefix *ucode) uc_value_t *v; int exitcode; - uc_search_path_init(&config.module_search_path); uc_vm_init(vm, &config); uc_stdlib_load(uc_vm_scope_get(vm)); @@ -430,6 +429,8 @@ ucode_plugin_init(const struct uhttpd_ops *o, struct config *c) ops = o; _conf = c; + uc_search_path_init(&config.module_search_path); + list_for_each_entry(p, &conf.ucode_prefix, list) uh_ucode_state_init(p); |