You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6a457d6
Browse filesBrowse the repository at this point in the historyBrowse files
Fix #15264 FP knownConditionTrueFalse: then-block treated as always escaping when only one path through a nested if returns
The forward traversal carries the true path of an opaque condition past
the if on a fork. Since 4b66976 the main traversal also commits to the
false path (absolute assumption) when the then-branch falls through. When
the main path later escapes, the traversal reported Terminate::Escape
although the fork fell through, so afterCondition() considered the block
dead.
A fork that is carried to the end of the whole traversal, or stops
because the value is modified, now makes the result fall through,
together with its actions. A fork that stops for another reason, or a
then-path that stops in the branch or is not followed (fork limits), is
unknown: if the main path escapes, the result is Terminate::Bail. The result stays
Terminate::Escape if the traversed range ends with an escape.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -4270,6 +4271,25 @@ class TestNullPointer : public TestFixture {
4270
4271
ASSERT_EQUALS("", errout_str());
4271
4272
}
4272
4273
4274
+
voidnullpointerAfterConditionalEscape() {
4275
+
// the then-block falls through when g() is true, so p can be null after it
4276
+
check("bool g();\n"
4277
+
"void use(int);\n"
4278
+
"void f(int *p) {\n"
4279
+
" if (!p) {\n"
4280
+
" bool w = false;\n"
4281
+
" if (g())\n"
4282
+
" w = true;\n"
4283
+
" if (!w)\n"
4284
+
" return;\n"
4285
+
" }\n"
4286
+
" use(*p);\n"
4287
+
"}\n");
4288
+
ASSERT_EQUALS(
4289
+
"[test.cpp:4:9] -> [test.cpp:11:10]: (warning) Either the condition '!p' is redundant or there is possible null pointer dereference: p. [nullPointerRedundantCheck]\n",
0 commit comments