From c921508f7978e2c4551a27c485abe814e1da0671 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 27 Feb 2026 12:06:50 +0100 Subject: [PATCH 1/3] Update astutils.cpp --- lib/astutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index e140d965114..2330a9d2b94 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -2499,7 +2499,7 @@ bool isMutableExpression(const Token* tok) if (const Variable* var = tok->variable()) { if (var->nameToken() == tok) return false; - if (!var->isPointer() && var->isConst()) + if (var->isConst() && !var->isPointer() && (!var->isArray() || !var->isArgument())) return false; } return true; From 7fd2f5927f7ff06e2ac94be3ba0e0dd488841acf Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 27 Feb 2026 12:08:17 +0100 Subject: [PATCH 2/3] Update testnullpointer.cpp --- test/testnullpointer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index f2664b05285..1f6a4096e74 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -995,6 +995,14 @@ class TestNullPointer : public TestFixture { "char f(S* s) { return s->p ? 'a' : s->p->c; }\n"); ASSERT_EQUALS("[test.cpp:2:24] -> [test.cpp:2:37]: (warning) Either the condition 's->p' is redundant or there is possible null pointer dereference: s->p. [nullPointerRedundantCheck]\n", errout_str()); + + check("int f(const int a[]) {\n" // #14544 + " int i = 0;\n" + " if (!a)\n" + " a = &i;\n" + " return *a;\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void nullpointer5() { From 7ca83dfe203ba87c0544363db8c0ab49534b355b Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 27 Feb 2026 12:58:47 +0100 Subject: [PATCH 3/3] Format --- test/testnullpointer.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 1f6a4096e74..37107397a44 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -997,11 +997,11 @@ class TestNullPointer : public TestFixture { errout_str()); check("int f(const int a[]) {\n" // #14544 - " int i = 0;\n" - " if (!a)\n" - " a = &i;\n" - " return *a;\n" - "}\n"); + " int i = 0;\n" + " if (!a)\n" + " a = &i;\n" + " return *a;\n" + "}\n"); ASSERT_EQUALS("", errout_str()); }