Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -2276,9 +2276,10 @@ return true; } -static bool checkIfNewOrNewArrayFamily(const RefState *RS) { +static bool checkIfAllocatedFamily(const RefState *RS) { return (RS->getAllocationFamily() == AF_CXXNewArray || - RS->getAllocationFamily() == AF_CXXNew); + RS->getAllocationFamily() == AF_CXXNew || + RS->getAllocationFamily() == AF_Malloc); } ProgramStateRef MallocChecker::checkPointerEscape(ProgramStateRef State, @@ -2293,7 +2294,7 @@ const CallEvent *Call, PointerEscapeKind Kind) const { return checkPointerEscapeAux(State, Escaped, Call, Kind, - &checkIfNewOrNewArrayFamily); + &checkIfAllocatedFamily); } ProgramStateRef MallocChecker::checkPointerEscapeAux(ProgramStateRef State, Index: test/Analysis/malloc.c =================================================================== --- test/Analysis/malloc.c +++ test/Analysis/malloc.c @@ -1095,7 +1095,7 @@ void r11160612_2() { char *x = malloc(12); const_ptr_and_callback(0, x, 12, 0); -} // expected-warning {{leak}} +} // no - warning // Callback is passed to a function defined in a system header. void r11160612_4() { @@ -1304,7 +1304,7 @@ void testPassConstPointer() { char * string = malloc(sizeof(char)*10); passConstPtr(string); - return; // expected-warning {{leak}} + return; //no-warning } void testPassConstPointerIndirectly() { Index: test/Analysis/malloc.cpp =================================================================== --- test/Analysis/malloc.cpp +++ test/Analysis/malloc.cpp @@ -34,7 +34,7 @@ void r11160612_no_callback() { char *x = (char*)malloc(12); const_ptr_and_callback_def_param_null(0, x, 12); -} // expected-warning{{leak}} +} // no-warning // Test member function pointer. struct CanFreeMemory { @@ -105,4 +105,4 @@ void fooNested(const char* name) { char* getterName = strdup(name); appendWrapperNested(getterName); // no-warning -} \ No newline at end of file +}