[FFmpeg-cvslog] tools/coverity: Add models for av_mallocz and av_free

Philip Langdale git at videolan.org
Wed Nov 30 23:28:01 EET 2016


ffmpeg | branch: master | Philip Langdale <philipl at overt.org> | Sun Nov 27 11:16:18 2016 -0800| [5eb68520635d895bbd878abf29fdb66872cbe00e] | committer: Philip Langdale

tools/coverity: Add models for av_mallocz and av_free

This should deal with some false positives, but might lead to
more of them depending on whether it realises that av_freep()
wraps av_free() or not.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5eb68520635d895bbd878abf29fdb66872cbe00e
---

 tools/coverity.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/tools/coverity.c b/tools/coverity.c
index 80fc1c2..3cc248c 100644
--- a/tools/coverity.c
+++ b/tools/coverity.c
@@ -35,8 +35,30 @@
 void *av_malloc(size_t size) {
     int has_memory;
     __coverity_negative_sink__(size);
-    if(has_memory)
-        return __coverity_alloc__(size);
-    else
+    if (has_memory) {
+        void *ptr = __coverity_alloc__(size);
+        __coverity_mark_as_uninitialized_buffer__(ptr);
+        __coverity_mark_as_afm_allocated__(ptr, "av_free");
+         return ptr;
+    } else {
         return 0;
+    }
+}
+
+void *av_mallocz(size_t size) {
+    int has_memory;
+    __coverity_negative_sink__(size);
+    if (has_memory) {
+        void *ptr = __coverity_alloc__(size);
+        __coverity_writeall0__(ptr);
+        __coverity_mark_as_afm_allocated__(ptr, "av_free");
+        return ptr;
+    } else {
+        return 0;
+    }
+}
+
+void *av_free(void *ptr) {
+    __coverity_free__(ptr);
+    __coverity_mark_as_afm_freed__(ptr, "av_free");
 }



More information about the ffmpeg-cvslog mailing list