@ -50,6 +50,10 @@ static int rle_uncompress(GetByteContext *gb, PutByteContext *pb, GetByteContext
if ( run = = 0 ) {
if ( run = = 0 ) {
run = bytestream2_get_le32 ( gb ) ;
run = bytestream2_get_le32 ( gb ) ;
if ( bytestream2_tell_p ( pb ) + width - w < run )
return AVERROR_INVALIDDATA ;
for ( int j = 0 ; j < run ; j + + , w + + ) {
for ( int j = 0 ; j < run ; j + + , w + + ) {
if ( w = = width ) {
if ( w = = width ) {
w = 0 ;
w = 0 ;
@ -61,6 +65,10 @@ static int rle_uncompress(GetByteContext *gb, PutByteContext *pb, GetByteContext
int pos = bytestream2_tell_p ( pb ) ;
int pos = bytestream2_tell_p ( pb ) ;
bytestream2_seek ( gbp , pos , SEEK_SET ) ;
bytestream2_seek ( gbp , pos , SEEK_SET ) ;
if ( pos + width - w < fill )
return AVERROR_INVALIDDATA ;
for ( int j = 0 ; j < fill ; j + + , w + + ) {
for ( int j = 0 ; j < fill ; j + + , w + + ) {
if ( w = = width ) {
if ( w = = width ) {
w = 0 ;
w = 0 ;
@ -72,6 +80,9 @@ static int rle_uncompress(GetByteContext *gb, PutByteContext *pb, GetByteContext
intra = 0 ;
intra = 0 ;
} else {
} else {
if ( bytestream2_tell_p ( pb ) + width - w < run )
return AVERROR_INVALIDDATA ;
for ( int j = 0 ; j < run ; j + + , w + + ) {
for ( int j = 0 ; j < run ; j + + , w + + ) {
if ( w = = width ) {
if ( w = = width ) {
w = 0 ;
w = 0 ;