diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-10-11 09:23:39 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-10-11 09:23:39 +0300 |
commit | af16d43af82ad0d05710c42232332a400614d3ea (patch) | |
tree | 5b4861c9d3ccc84ab95ebafa88340ab649e3a3d2 /src | |
parent | 71bf522231d2998f1fb183f343c2b1f9dbcd3b15 (diff) | |
download | sciteco-af16d43af82ad0d05710c42232332a400614d3ea.tar.gz |
fixed crashes when the Q-Reg stack is non-empty at exit
* Test case: sciteco -e '[a'
[aEX$$ in interactive mode would also crash.
* No longer use a destructor - it was executed after the Q-Reg view was
destroyed.
* Instead, we now explicitly call teco_qreg_stack_clear() in main().
* Added a regression test case.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 1 | ||||
-rw-r--r-- | src/qreg.c | 4 | ||||
-rw-r--r-- | src/qreg.h | 1 |
3 files changed, 3 insertions, 3 deletions
@@ -457,6 +457,7 @@ cleanup: teco_ring_cleanup(); teco_qreg_table_clear(&local_qregs); teco_qreg_table_clear(&teco_qreg_table_globals); + teco_qreg_stack_clear(); teco_view_free(teco_qreg_view); #endif teco_interface_cleanup(); @@ -1140,14 +1140,12 @@ teco_qreg_stack_pop(teco_qreg_t *qreg, GError **error) return TRUE; } -#ifndef NDEBUG -static void __attribute__((destructor)) +void teco_qreg_stack_clear(void) { g_array_set_clear_func(teco_qreg_stack, (GDestroyNotify)teco_qreg_stack_entry_clear); g_array_free(teco_qreg_stack, TRUE); } -#endif gboolean teco_ed_hook(teco_ed_hook_t type, GError **error) @@ -179,6 +179,7 @@ extern teco_qreg_table_t teco_qreg_table_globals; gboolean teco_qreg_stack_push(teco_qreg_t *qreg, GError **error); gboolean teco_qreg_stack_pop(teco_qreg_t *qreg, GError **error); +void teco_qreg_stack_clear(void); typedef enum { TECO_ED_HOOK_ADD = 1, |