diff options
author | Sergey Vinokurov <serg.foo@gmail.com> | 2018-08-19 21:31:01 +0100 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2018-08-25 18:57:56 -0400 |
commit | 54fb383af6f6af7b72c28f38b308d9b24d2af4f6 (patch) | |
tree | edc7291d8ae2c17a2e5d0b7e5d29546b93660bcd /test/data/emacs-module/mod-test.c | |
parent | 769d0cdaa9a986b74e30dfc589e1fa8115e1d401 (diff) | |
download | emacs-54fb383af6f6af7b72c28f38b308d9b24d2af4f6.tar.gz emacs-54fb383af6f6af7b72c28f38b308d9b24d2af4f6.tar.bz2 emacs-54fb383af6f6af7b72c28f38b308d9b24d2af4f6.zip |
Fix detection of freed emacs_values (Bug#32479)
* src/emacs-module.c (module_free_global_ref): Compare a value to be
freed with all entries of the list.
* test/data/emacs-module/mod-test.c (Fmod_test_globref_free): New
function.
(emacs_module_init): Make it accessible from Lisp.
* test/src/emacs-module-tests.el (mod-test-globref-free-test): New
test which uses it.
Diffstat (limited to 'test/data/emacs-module/mod-test.c')
-rw-r--r-- | test/data/emacs-module/mod-test.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c index a1c115f00d2..4c783faeeae 100644 --- a/test/data/emacs-module/mod-test.c +++ b/test/data/emacs-module/mod-test.c @@ -156,6 +156,24 @@ Fmod_test_globref_make (emacs_env *env, ptrdiff_t nargs, emacs_value args[], return env->make_global_ref (env, lisp_str); } +/* Create a few global references from arguments and free them. */ +static emacs_value +Fmod_test_globref_free (emacs_env *env, ptrdiff_t nargs, emacs_value args[], + void *data) +{ + emacs_value refs[10]; + for (int i = 0; i < 10; i++) + { + refs[i] = env->make_global_ref (env, args[i % nargs]); + } + for (int i = 0; i < 10; i++) + { + env->free_global_ref (env, refs[i]); + } + return env->intern (env, "ok"); +} + + /* Return a copy of the argument string where every 'a' is replaced with 'b'. */ @@ -339,6 +357,7 @@ emacs_module_init (struct emacs_runtime *ert) DEFUN ("mod-test-non-local-exit-funcall", Fmod_test_non_local_exit_funcall, 1, 1, NULL, NULL); DEFUN ("mod-test-globref-make", Fmod_test_globref_make, 0, 0, NULL, NULL); + DEFUN ("mod-test-globref-free", Fmod_test_globref_free, 4, 4, NULL, NULL); DEFUN ("mod-test-string-a-to-b", Fmod_test_string_a_to_b, 1, 1, NULL, NULL); DEFUN ("mod-test-userptr-make", Fmod_test_userptr_make, 1, 1, NULL, NULL); DEFUN ("mod-test-userptr-get", Fmod_test_userptr_get, 1, 1, NULL, NULL); |