From d6b37ca5112badba0697a73ba0a149d7973e5dc3 Mon Sep 17 00:00:00 2001 From: Charlie Gordon Date: Mon, 18 May 2026 00:07:26 +0200 Subject: [PATCH] Sundries: bug fixes * fix crash bug on `delete_equivalent()`: qe_free takes a double pointer * remove unused ShellState variables * initialize term structures --- extras.c | 6 +++--- modes/shell.c | 3 +-- qe.c | 2 +- qe.h | 2 +- tty.c | 4 ++-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/extras.c b/extras.c index 8ed113c..cd75cf9 100644 --- a/extras.c +++ b/extras.c @@ -44,9 +44,9 @@ Equivalent *create_equivalent(const char *str1, const char *str2) { } void delete_equivalent(Equivalent *ep) { - qe_free(ep->str1); - qe_free(ep->str2); - qe_free(ep); + qe_free(&ep->str1); + qe_free(&ep->str2); + qe_free(&ep); } static void do_define_equivalent(EditState *s, const char *str1, const char *str2) diff --git a/modes/shell.c b/modes/shell.c index e34efbd..8b98887 100644 --- a/modes/shell.c +++ b/modes/shell.c @@ -76,7 +76,6 @@ typedef struct ShellState { int params[MAX_CSI_PARAMS + 1]; int state; int esc1, esc2; - int this_byte, last_byte; char32_t lastc; int shifted; int cset, charset[2]; @@ -114,7 +113,7 @@ typedef struct ShellKillContext { EditBuffer *b; void (*callback)(EditState*, const char*); EditState *e; - const char *cmd; + char *cmd; /* allocated */ } ShellKillContext; static ShellError error_state = { diff --git a/qe.c b/qe.c index 34b4834..35d4f8c 100644 --- a/qe.c +++ b/qe.c @@ -12098,7 +12098,7 @@ int main(int argc, char **argv) if (vp->str_alloc) qe_free(&vp->value.str); if (vp->var_alloc) { - qe_free(&vp->name); + qe_free(unconst(char **)&vp->name); qe_free(&vp); } } diff --git a/qe.h b/qe.h index 376fe85..0062a03 100644 --- a/qe.h +++ b/qe.h @@ -1185,7 +1185,7 @@ typedef enum CmdSig { typedef union CmdArg { EditState *s; void *vp; - const char *p; + char *p; /* allocated */ int n; } CmdArg; diff --git a/tty.c b/tty.c index 15feedc..c512cbb 100644 --- a/tty.c +++ b/tty.c @@ -289,8 +289,8 @@ static int tty_dpy_init(QEditScreen *s, QEmacsState *qs, qe__unused__ int w, qe__unused__ int h) { TTYState *ts; - struct termios tty; - struct sigaction sig; + struct termios tty = { 0 }; + struct sigaction sig = { 0 }; const char *p; ts = qe_mallocz(TTYState);