1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-16 09:50:25 +00:00

Fix double-free bug when finalizing module runtimes.

* src/emacs-module.c (finalize_runtime_unwind): Don't finalize initial
environment twice.

* test/src/emacs-module-resources/mod-test.c (emacs_module_init):
Allocate lots of values during module initialization to trigger the
bug.
This commit is contained in:
Philipp Stephani 2020-11-29 21:13:02 +01:00
parent 367727b0f6
commit 41c338474d
2 changed files with 8 additions and 2 deletions

View File

@ -1506,8 +1506,8 @@ finalize_environment_unwind (void *env)
void
finalize_runtime_unwind (void *raw_ert)
{
struct emacs_runtime *ert = raw_ert;
finalize_environment (ert->private_members->env);
/* No further cleanup is required, as the initial environment is
unwound separately. See the logic in Fmodule_load. */
}

View File

@ -806,6 +806,12 @@ emacs_module_init (struct emacs_runtime *ert)
strlen (interactive_spec)));
bind_function (env, "mod-test-identity", identity_fn);
/* We allocate lots of values to trigger bugs in the frame allocator during
initialization. */
int count = 10000; /* larger than value_frame_size in emacs-module.c */
for (int i = 0; i < count; ++i)
env->make_integer (env, i);
provide (env, "mod-test");
return 0;
}