diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 7462ec5984..f0f56efa9e 100644 --- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -538,11 +538,8 @@ void MallocChecker::ReallocMem(CheckerContext &C, const CallExpr *CE) const { if (const ProgramState *stateFree = FreeMemAux(C, CE, stateSizeZero, 0, false)) { - // Add the state transition to set input pointer argument to be free. - C.addTransition(stateFree); - - // Bind the return value to UndefinedVal because it is now free. - C.addTransition(stateFree->BindExpr(CE, UndefinedVal(), true)); + // Bind the return value to NULL because it is now free. + C.addTransition(stateFree->BindExpr(CE, svalBuilder.makeNull(), true)); } if (const ProgramState *stateSizeNotZero = stateNotEqual->assume(SizeZero,false)) if (const ProgramState *stateFree = FreeMemAux(C, CE, stateSizeNotZero, diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c index dce9e4b5b2..d9087ab830 100644 --- a/test/Analysis/malloc.c +++ b/test/Analysis/malloc.c @@ -41,7 +41,7 @@ void f2_realloc_0() { void f2_realloc_1() { int *p = malloc(12); - int *q = realloc(p,0); // expected-warning{{Assigned value is garbage or undefined}} + int *q = realloc(p,0); // no-warning } // ownership attributes tests