@@ -70,6 +70,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
70
70
int buf_size = avpkt -> size ;
71
71
CamStudioContext * c = avctx -> priv_data ;
72
72
int ret ;
73
+ int bpp = avctx -> bits_per_coded_sample / 8 ;
74
+ int bugdelta = FFALIGN (avctx -> width * bpp , 4 ) * avctx -> height
75
+ - (avctx -> width & ~3 ) * bpp * avctx -> height ;
73
76
74
77
if (buf_size < 2 ) {
75
78
av_log (avctx , AV_LOG_ERROR , "coded frame too small\n" );
@@ -83,9 +86,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
83
86
switch ((buf [0 ] >> 1 ) & 7 ) {
84
87
case 0 : { // lzo compression
85
88
int outlen = c -> decomp_size , inlen = buf_size - 2 ;
86
- int bpp = avctx -> bits_per_coded_sample / 8 ;
87
- int bugdelta = FFALIGN (avctx -> width * bpp , 4 ) * avctx -> height
88
- - (avctx -> width & ~3 ) * bpp * avctx -> height ;
89
89
if (av_lzo1x_decode (c -> decomp_buf , & outlen , & buf [2 ], & inlen ) || (outlen && outlen != bugdelta )) {
90
90
av_log (avctx , AV_LOG_ERROR , "error during lzo decompression\n" );
91
91
return AVERROR_INVALIDDATA ;
@@ -95,7 +95,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe,
95
95
case 1 : { // zlib compression
96
96
#if CONFIG_ZLIB
97
97
unsigned long dlen = c -> decomp_size ;
98
- if (uncompress (c -> decomp_buf , & dlen , & buf [2 ], buf_size - 2 ) != Z_OK || dlen != c -> decomp_size ) {
98
+ if (uncompress (c -> decomp_buf , & dlen , & buf [2 ], buf_size - 2 ) != Z_OK || ( dlen != c -> decomp_size && dlen != c -> decomp_size - bugdelta ) ) {
99
99
av_log (avctx , AV_LOG_ERROR , "error during zlib decompression\n" );
100
100
return AVERROR_INVALIDDATA ;
101
101
}
0 commit comments