Browse code

pthread: don't increment index on zero-sized packets.

The next call to decode() will update from an invalid index, which will
either lead to a memcpy() where dest==src (2 threads), or lead to a
crash (>2 threads).

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>

Aaron Colwell authored on 2011/11/29 00:23:03
Showing 1 changed files
... ...
@@ -491,6 +491,7 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
491 491
     }
492 492
 
493 493
     fctx->prev_thread = p;
494
+    fctx->next_decoding++;
494 495
 
495 496
     return 0;
496 497
 }
... ...
@@ -513,8 +514,6 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
513 513
     err = submit_packet(p, avpkt);
514 514
     if (err) return err;
515 515
 
516
-    fctx->next_decoding++;
517
-
518 516
     /*
519 517
      * If we're still receiving the initial packets, don't return a frame.
520 518
      */