diff options
author | Philipp Stephani <phst@google.com> | 2020-11-29 21:13:02 +0100 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2020-11-29 21:13:02 +0100 |
commit | 41c338474dd1e086494337fd18ec8828cef1a75c (patch) | |
tree | 31e090e26e3bda495f984c0a634e21cfe0ecf0ce /test/src/emacs-module-resources/mod-test.c | |
parent | 367727b0f6ed2468c909b9883740bff101d5a68f (diff) | |
download | emacs-41c338474dd1e086494337fd18ec8828cef1a75c.tar.gz emacs-41c338474dd1e086494337fd18ec8828cef1a75c.tar.bz2 emacs-41c338474dd1e086494337fd18ec8828cef1a75c.zip |
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.
Diffstat (limited to 'test/src/emacs-module-resources/mod-test.c')
-rw-r--r-- | test/src/emacs-module-resources/mod-test.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/src/emacs-module-resources/mod-test.c b/test/src/emacs-module-resources/mod-test.c index 419621256ae..f855e9b6da0 100644 --- a/test/src/emacs-module-resources/mod-test.c +++ b/test/src/emacs-module-resources/mod-test.c @@ -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; } |