[PATCH] D9040: [analyzer] Make realloc(ptr, 0) handling equivalent to malloc(0).

Anna Zaks via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 21 18:45:05 PDT 2015


zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

See the suggestion for an improved comment. Otherwise, LGTM!

Thanks!
Anna.


================
Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:902
@@ +901,3 @@
+    } else {
+      // Case of zero-size realloc. Historically 'realloc(ptr, 0)' is treated as
+      // 'free(ptr)' and the returned value from 'realloc(ptr, 0)' is not
----------------
"Historically 'realloc(ptr, 0)' is treated as 'free(ptr)' and the returned value from 'realloc(ptr, 0)' is not tracked." -> "The value returned from 'realloc(ptr, 0)' is not tracked since historically 'realloc(ptr, 0)' is treated as 'free(ptr)' and the analyzer supports that model. However, we want to report uses of zero-allocated memory that get returned by realloc."


http://reviews.llvm.org/D9040





More information about the cfe-commits mailing list