aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2021-10-11 09:23:39 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2021-10-11 09:23:39 +0300
commitaf16d43af82ad0d05710c42232332a400614d3ea (patch)
tree5b4861c9d3ccc84ab95ebafa88340ab649e3a3d2 /src
parent71bf522231d2998f1fb183f343c2b1f9dbcd3b15 (diff)
downloadsciteco-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.c1
-rw-r--r--src/qreg.c4
-rw-r--r--src/qreg.h1
3 files changed, 3 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 38b1197..797ef73 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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();
diff --git a/src/qreg.c b/src/qreg.c
index 5c39409..84bc217 100644
--- a/src/qreg.c
+++ b/src/qreg.c
@@ -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)
diff --git a/src/qreg.h b/src/qreg.h
index 4797a01..6199b31 100644
--- a/src/qreg.h
+++ b/src/qreg.h
@@ -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,