fold/tests/fixtures/binary/cwe/cwe476_nullderef.c
trvon fd4a68dfff
test: add coverage for project graph, pcode encoder, and detector behaviors
Unit + integration coverage for the session's work: incremental project
graph/index, pcode encoder, unreachable/dead-branch, equiv/cross-TU,
div-by-zero/sign-conversion/int-truncation, use-after-free, quality-precision,
scan-router profile, source TU runner, detector plan, and the eval fixtures.
2026-08-16 16:46:07 -06:00

11 lines
345 B
C

// CWE-476: null pointer dereference (unchecked malloc/argv pointer).
#include <stdlib.h>
__attribute__((noinline)) int vuln(int* p) {
return *p; // sink: deref of possibly-null p
}
int main(int argc, char** argv) {
int* p = 0;
if (argc > 1)
p = (int*)argv; // attacker-controlled, may be null in tests
return vuln(p);
}