Quell more valgrind warnings.
authorCarl Hetherington <cth@carlh.net>
Thu, 6 Sep 2018 00:27:19 +0000 (01:27 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 6 Sep 2018 00:27:19 +0000 (01:27 +0100)
src/lib/image.cc

index b75c0f083bd9bcb5cedcd423d388aea5e1df760b..75345cb068ae5363416c2823b5fb9cbbdd36c2c6 100644 (file)
@@ -37,6 +37,9 @@ extern "C" {
 #include <libavutil/pixdesc.h>
 #include <libavutil/frame.h>
 }
+#if HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
 #include <iostream>
 
 #include "i18n.h"
@@ -850,6 +853,12 @@ Image::allocate ()
                   testing suggests that it works.
                */
                _data[i] = (uint8_t *) wrapped_av_malloc (_stride[i] * sample_size(i).height + _extra_pixels * bytes_per_pixel(i) + 32);
+#if HAVE_VALGRIND_MEMCHECK_H
+               /* The data between the end of the line size and the stride is undefined but processed by
+                  libswscale, causing lots of valgrind errors.  Mark it all defined to quell these errors.
+               */
+               VALGRIND_MAKE_MEM_DEFINED (_data[i], _stride[i] * sample_size(i).height + _extra_pixels * bytes_per_pixel(i) + 32);
+#endif
        }
 }