Browse code

dvbsubdec: Fix variable increments & checking in dvbsub_read_*bit_string()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

JULIAN GARDNER authored on 2011/10/14 21:52:33
Showing 1 changed files
... ...
@@ -532,14 +532,14 @@ static int dvbsub_read_2bit_string(uint8_t *destbuf, int dbuf_len,
532 532
                             }
533 533
                         }
534 534
                     } else if (bits == 1) {
535
-                        pixels_read += 2;
536 535
                         if (map_table)
537 536
                             bits = map_table[0];
538 537
                         else
539 538
                             bits = 0;
540
-                        if (pixels_read <= dbuf_len) {
541
-                            *destbuf++ = bits;
539
+                        run_length = 2;
540
+                        while (run_length-- > 0 && pixels_read < dbuf_len) {
542 541
                             *destbuf++ = bits;
542
+                            pixels_read++;
543 543
                         }
544 544
                     } else {
545 545
                         (*srcbuf) += (get_bits_count(&gb) + 7) >> 3;
... ...
@@ -656,14 +656,14 @@ static int dvbsub_read_4bit_string(uint8_t *destbuf, int dbuf_len,
656 656
                             }
657 657
                         }
658 658
                     } else if (bits == 1) {
659
-                        pixels_read += 2;
660 659
                         if (map_table)
661 660
                             bits = map_table[0];
662 661
                         else
663 662
                             bits = 0;
664
-                        if (pixels_read <= dbuf_len) {
665
-                            *destbuf++ = bits;
663
+                        run_length = 2;
664
+                        while (run_length-- > 0 && pixels_read < dbuf_len) {
666 665
                             *destbuf++ = bits;
666
+                            pixels_read++;
667 667
                         }
668 668
                     } else {
669 669
                         if (map_table)