]> git.sesse.net Git - x264/commitdiff
Fix invalid memcpy in sliced-threads
authorFiona Glaser <fiona@x264.com>
Wed, 8 May 2013 17:48:41 +0000 (10:48 -0700)
committerFiona Glaser <fiona@x264.com>
Wed, 15 May 2013 20:04:45 +0000 (13:04 -0700)
Likely didn't actually break in practice, but memcpy with src==dst
is incorrect.

encoder/ratecontrol.c

index cd76293a28662d338c64837ac67819a1ab4af827..dcc1e28d1622a74260b3fafcf0aff19562d61690 100644 (file)
@@ -2593,14 +2593,16 @@ void x264_threads_distribute_ratecontrol( x264_t *h )
     if( h->i_frame == 0 )
         for( int i = 0; i < h->param.i_threads; i++ )
         {
-            x264_ratecontrol_t *t = h->thread[i]->rc;
-            memcpy( t->row_preds, rc->row_preds, sizeof(rc->row_preds) );
+            x264_t *t = h->thread[i];
+            if( t != h )
+                memcpy( t->rc->row_preds, rc->row_preds, sizeof(rc->row_preds) );
         }
 
     for( int i = 0; i < h->param.i_threads; i++ )
     {
         x264_t *t = h->thread[i];
-        memcpy( t->rc, rc, offsetof(x264_ratecontrol_t, row_pred) );
+        if( t != h )
+            memcpy( t->rc, rc, offsetof(x264_ratecontrol_t, row_pred) );
         t->rc->row_pred = &t->rc->row_preds[h->sh.i_type];
         /* Calculate the planned slice size. */
         if( rc->b_vbv && rc->frame_size_planned )