diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -190,6 +190,9 @@ ProgramStateRef apply(ProgramStateRef State, const CallEvent &Call, const Summary &Summary) const override { SVal V = getArgSVal(Call, getArgNo()); + if (V.isUndef()) + return State; + DefinedOrUnknownSVal L = V.castAs(); if (!L.getAs()) return State; diff --git a/clang/test/Analysis/std-c-library-functions.c b/clang/test/Analysis/std-c-library-functions.c --- a/clang/test/Analysis/std-c-library-functions.c +++ b/clang/test/Analysis/std-c-library-functions.c @@ -89,6 +89,14 @@ clang_analyzer_eval(z <= y); // expected-warning{{TRUE}} } +void test_fread_uninitialized(void) { + void *ptr; + size_t sz; + size_t nmem; + FILE *fp; + (void)fread(ptr, sz, nmem, fp); // expected-warning {{1st function call argument is an uninitialized value}} +} + ssize_t getline(char **, size_t *, FILE *); void test_getline(FILE *fp) { char *line = 0;