fold/tests/fixtures/security/null_guarded.cpp
trvon 3f1234f7bb
fold: bounded symbolic SAST for C++
Clang LibTooling + Z3 BV-64 encoding.
11 detectors: clone, equiv, class-dup, dead, null-deref,
div-by-zero, int-overflow, oob, int-truncation,
sign-conversion, taint-track.

Interfaces: CLI, MCP (JSON-RPC 2.0), LSP.
Output: SARIF 2.1.0, JSON, Markdown.
2026-05-14 23:14:54 -04:00

10 lines
357 B
C++

// p starts as null but is reassigned before deref; future M7 follow-up
// will model the reassignment via the encoder. For today this fixture
// documents the false-positive shape — the current first-cut detector
// will flag it because it only sees the initializer.
int g_x = 0;
int null_guarded() {
int* p = nullptr;
p = &g_x;
return *p;
}