From 269cd0f8ac5a6cfe38914a6e0e0a7f4bdfebbdac Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 6 May 2025 16:53:09 +0200 Subject: [PATCH] xkb: maprules: fix potential NULL pointer dereference warnings Even though the cases might be hypothetical, it's still better having some tiny extra checks (that might be even optimized-out) and reduce the analyzer noise a bit. Signed-off-by: Enrico Weigelt, metux IT consult --- xkb/maprules.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xkb/maprules.c b/xkb/maprules.c index 8a1944ef5..f23f8a166 100644 --- a/xkb/maprules.c +++ b/xkb/maprules.c @@ -93,7 +93,9 @@ InputLineAddChar(InputLine * line, int ch) { if (line->num_line >= line->sz_line) { if (line->line == line->buf) { - line->line = xallocarray(line->sz_line, 2); + line->line = calloc(line->sz_line, 2); + if (line->line == NULL) + return -1; memcpy(line->line, line->buf, line->sz_line); } else { @@ -379,7 +381,7 @@ CheckLine(InputLine * line, _Xstrtokparams strtok_buf; Bool append = FALSE; - if (line->line[0] == '!') { + if (line && line->line && line->line[0] == '!') { if (line->line[1] == '$' || (line->line[1] == ' ' && line->line[2] == '$')) { char *gname = strchr(line->line, '$');