From 3ab68dd361828c78be35c1715906f2d3c2c565d6 Mon Sep 17 00:00:00 2001 From: NRK Date: Sun, 24 Apr 2022 06:10:12 +0600 Subject: [PATCH 1/3] properly close va_list --- Str.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Str.c b/Str.c index ac6446a..e4c1e69 100644 --- a/Str.c +++ b/Str.c @@ -105,6 +105,7 @@ Strnew_m_charp(const char *p, ...) Strcat_charp(r, p); p = va_arg(ap, char *); } + va_end(ap); return r; } @@ -276,6 +277,7 @@ Strcat_m_charp(Str x, ...) va_start(ap, x); while ((p = va_arg(ap, char *)) != NULL) Strcat_charp_n(x, p, strlen(p)); + va_end(ap); } void From b2ce5a9c54b971cb918706cac73d20e6fbd7c930 Mon Sep 17 00:00:00 2001 From: NRK Date: Sun, 24 Apr 2022 06:17:44 +0600 Subject: [PATCH 2/3] ensure map isn't NULL main.c:1460:22: warning: Possible null pointer dereference: map [nullPointer] w3mFuncList[(int)map[c]].func(); ^ main.c:1503:24: note: Calling function 'escKeyProc', 3rd argument 'NULL' value is 0 escKeyProc((int)c, 0, NULL); ^ main.c:1438:25: note: Assuming condition is Assuming condition is false if (CurrentKey >= 0 && CurrentKey & K_MULTI) { ^ main.c:1460:22: note: Null pointer dereference w3mFuncList[(int)map[c]].func(); ^ --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 005d9b2..45f5a4b 100644 --- a/main.c +++ b/main.c @@ -1457,7 +1457,8 @@ escKeyProc(int c, int esc, unsigned char *map) esc |= (CurrentKey & ~0xFFFF); } CurrentKey = esc | c; - w3mFuncList[(int)map[c]].func(); + if (map) + w3mFuncList[(int)map[c]].func(); } DEFUN(escmap, ESCMAP, "ESC map") From b155c9f7591942ad9fea8ca5775f8f8064d968ff Mon Sep 17 00:00:00 2001 From: NRK Date: Sun, 24 Apr 2022 06:25:53 +0600 Subject: [PATCH 3/3] check bound _before_ making access --- regex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regex.c b/regex.c index 93406e8..15c7b35 100644 --- a/regex.c +++ b/regex.c @@ -747,7 +747,7 @@ lc2c(longchar * x, int len) int i = 0, j = 0; char *r; - while (x[j].type != RE_TYPE_END && j < len) { + while (j < len && x[j].type != RE_TYPE_END) { if (x[j].type == RE_WHICH_RANGE) y[i++] = '-'; #ifdef USE_M17N