diff options
| author | Sergey Vinokurov | 2018-08-19 21:31:01 +0100 |
|---|---|---|
| committer | Noam Postavsky | 2018-08-25 18:57:56 -0400 |
| commit | 54fb383af6f6af7b72c28f38b308d9b24d2af4f6 (patch) | |
| tree | edc7291d8ae2c17a2e5d0b7e5d29546b93660bcd /src | |
| parent | 769d0cdaa9a986b74e30dfc589e1fa8115e1d401 (diff) | |
| download | emacs-54fb383af6f6af7b72c28f38b308d9b24d2af4f6.tar.gz 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 'src')
| -rw-r--r-- | src/emacs-module.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index 1b19e8033df..c20902d0729 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -334,20 +334,20 @@ module_free_global_ref (emacs_env *env, emacs_value ref) | |||
| 334 | Lisp_Object globals = global_env_private.values; | 334 | Lisp_Object globals = global_env_private.values; |
| 335 | Lisp_Object prev = Qnil; | 335 | Lisp_Object prev = Qnil; |
| 336 | ptrdiff_t count = 0; | 336 | ptrdiff_t count = 0; |
| 337 | for (Lisp_Object tail = global_env_private.values; CONSP (tail); | 337 | for (Lisp_Object tail = globals; CONSP (tail); |
| 338 | tail = XCDR (tail)) | 338 | tail = XCDR (tail)) |
| 339 | { | 339 | { |
| 340 | emacs_value global = XSAVE_POINTER (XCAR (globals), 0); | 340 | emacs_value global = XSAVE_POINTER (XCAR (tail), 0); |
| 341 | if (global == ref) | 341 | if (global == ref) |
| 342 | { | 342 | { |
| 343 | if (NILP (prev)) | 343 | if (NILP (prev)) |
| 344 | global_env_private.values = XCDR (globals); | 344 | global_env_private.values = XCDR (globals); |
| 345 | else | 345 | else |
| 346 | XSETCDR (prev, XCDR (globals)); | 346 | XSETCDR (prev, XCDR (tail)); |
| 347 | return; | 347 | return; |
| 348 | } | 348 | } |
| 349 | ++count; | 349 | ++count; |
| 350 | prev = globals; | 350 | prev = tail; |
| 351 | } | 351 | } |
| 352 | module_abort ("Global value was not found in list of %"pD"d globals", | 352 | module_abort ("Global value was not found in list of %"pD"d globals", |
| 353 | count); | 353 | count); |