[vlc-commits] demux/image: add an assertion

Rémi Denis-Courmont git at videolan.org
Sun Mar 3 10:25:10 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Mar  3 10:45:06 2019 +0200| [30cf7c8f7d39406b62953f120ba90aa9675355ff] | committer: Rémi Denis-Courmont

demux/image: add an assertion

memcmp() over an invalid pointer is undefined. If the marker size is
larger than zero, we can assume that the peek pointer is valid, after
vlc_stream_Peek() succeeds.

The assertion makes sense insofar as a marker size of zero would
essentially match every possible input, and should never be usedn.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=30cf7c8f7d39406b62953f120ba90aa9675355ff
---

 modules/demux/image.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/modules/demux/image.c b/modules/demux/image.c
index c1e99e11b5..b7a424b861 100644
--- a/modules/demux/image.c
+++ b/modules/demux/image.c
@@ -28,6 +28,8 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_demux.h>
@@ -670,6 +672,8 @@ static vlc_fourcc_t Detect(stream_t *s)
                 continue;
         }
 
+        assert(img->marker_size > 0); /* ensure peek is a valid pointer */
+
         if (peek_size >= img->marker_size
          && memcmp(peek, img->marker, img->marker_size) == 0)
             return img->codec;



More information about the vlc-commits mailing list