Prevent NULL dereferences when the previous frame is missing in vmd video decoder.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 6a6383bebc
)
This commit is contained in:

committed by
Michael Niedermayer

parent
1ed90c84f6
commit
d92bfc98f9
@@ -226,8 +226,9 @@ static void vmd_decode(VmdVideoContext *s)
|
|||||||
|
|
||||||
/* if only a certain region will be updated, copy the entire previous
|
/* if only a certain region will be updated, copy the entire previous
|
||||||
* frame before the decode */
|
* frame before the decode */
|
||||||
if (frame_x || frame_y || (frame_width != s->avctx->width) ||
|
if (s->prev_frame.data[0] &&
|
||||||
(frame_height != s->avctx->height)) {
|
(frame_x || frame_y || (frame_width != s->avctx->width) ||
|
||||||
|
(frame_height != s->avctx->height))) {
|
||||||
|
|
||||||
memcpy(s->frame.data[0], s->prev_frame.data[0],
|
memcpy(s->frame.data[0], s->prev_frame.data[0],
|
||||||
s->avctx->height * s->frame.linesize[0]);
|
s->avctx->height * s->frame.linesize[0]);
|
||||||
@@ -272,7 +273,7 @@ static void vmd_decode(VmdVideoContext *s)
|
|||||||
ofs += len;
|
ofs += len;
|
||||||
} else {
|
} else {
|
||||||
/* interframe pixel copy */
|
/* interframe pixel copy */
|
||||||
if (ofs + len + 1 > frame_width)
|
if (ofs + len + 1 > frame_width || !s->prev_frame.data[0])
|
||||||
return;
|
return;
|
||||||
memcpy(&dp[ofs], &pp[ofs], len + 1);
|
memcpy(&dp[ofs], &pp[ofs], len + 1);
|
||||||
ofs += len + 1;
|
ofs += len + 1;
|
||||||
@@ -312,7 +313,7 @@ static void vmd_decode(VmdVideoContext *s)
|
|||||||
ofs += len;
|
ofs += len;
|
||||||
} else {
|
} else {
|
||||||
/* interframe pixel copy */
|
/* interframe pixel copy */
|
||||||
if (ofs + len + 1 > frame_width)
|
if (ofs + len + 1 > frame_width || !s->prev_frame.data[0])
|
||||||
return;
|
return;
|
||||||
memcpy(&dp[ofs], &pp[ofs], len + 1);
|
memcpy(&dp[ofs], &pp[ofs], len + 1);
|
||||||
ofs += len + 1;
|
ofs += len + 1;
|
||||||
|
Reference in New Issue
Block a user