Expand the over-allocation of image buffers to 32 bytes to attempt to avoid bad reads...
authorCarl Hetherington <cth@carlh.net>
Mon, 2 Jun 2014 13:59:10 +0000 (14:59 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 2 Jun 2014 13:59:10 +0000 (14:59 +0100)
ChangeLog
src/lib/image.cc

index bd7ec7c621edf3f6d1e2cbe3cd67b0aa0cbf23b1..a14a93a0e1d33edccd19dcbd6d69802b099acbf7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-02  Carl Hetherington  <cth@carlh.net>
+
+       * Empirical hack to prevent over-read of array
+       by libswscale; may fix crashes at the start of
+       DCP encodes.
+
 2014-05-29  Carl Hetherington  <cth@carlh.net>
 
        * Version 1.69.18 released.
index 1fa55e24209ed099ba43bf03cda8693c13e57067..e8622eba4c90276f2f5440a47911332110928865 100644 (file)
@@ -490,8 +490,13 @@ Image::allocate ()
                   OS X crashes on this illegal read, though other operating systems don't
                   seem to mind.  The nasty + 1 in this malloc makes sure there is always a byte
                   for that instruction to read safely.
+
+                  Further to the above, valgrind is now telling me that ff_rgb24ToY_ssse3
+                  over-reads by more then _avx.  I can't follow the code to work out how much,
+                  so I'll just over-allocate by 32 bytes and have done with it.  Empirical
+                  testing suggests that it works.
                */
-               _data[i] = (uint8_t *) wrapped_av_malloc (_stride[i] * lines (i) + 1);
+               _data[i] = (uint8_t *) wrapped_av_malloc (_stride[i] * lines (i) + 32);
        }
 }