Add the check for the return value of the av_malloc in order to avoid NULL pointer deference.
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -84,6 +84,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 83 unmodified lines | ||
| 84 | 84 | |
| 85 | 85 | if(!c->prev) |
| 86 | 86 | c->prev = av_malloc(avctx->width * 3 * (avctx->height + 3)); |
| 87 | + if (!c->prev) | |
| 88 | + return AVERROR(ENOMEM); | |
| 87 | 89 | prevptr = c->prev + avctx->width * 3 * (FFALIGN(avctx->height, 4) - 1); |
| 88 | 90 | src = (const uint16_t*)(p->data[0] + p->linesize[0]*(FFALIGN(avctx->height, 4) - 1)); |
| 89 | 91 | if(c->keyint >= avctx->keyint_min) |