Quoting Vittorio Giovara (2015-09-27 16:39:54)
> Signed-off-by: Vittorio Giovara <[email protected]>
> ---
> In this version:
>  - added pkt size check
>  - reworded comments a little
>  - included fate test
> 
> Big thanks to nevcariel for providing the test file.
> Vittorio
> 
>  Changelog                   |   1 +
>  configure                   |   1 +
>  doc/general.texi            |   1 +
>  libavcodec/Makefile         |   1 +
>  libavcodec/allcodecs.c      |   1 +
>  libavcodec/avcodec.h        |   1 +
>  libavcodec/codec_desc.c     |   7 ++
>  libavcodec/screenpresso.c   | 190 
> ++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/version.h        |   2 +-
>  libavformat/riff.c          |   1 +
>  tests/fate/video.mak        |   3 +
>  tests/ref/fate/screenpresso |   5 ++
>  12 files changed, 213 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/screenpresso.c
>  create mode 100644 tests/ref/fate/screenpresso
> 
> +static int screenpresso_decode_frame(AVCodecContext *avctx, void *data,
> +                                     int *got_frame, AVPacket *avpkt)
> +{
> +    ScreenpressoContext *ctx = avctx->priv_data;
> +    AVFrame *frame = data;
> +    int keyframe;
> +    int ret;
> +
> +    /* Size check */
> +    if (avpkt->size < 3) {
> +        av_log(avctx, AV_LOG_ERROR, "Packet too small (%d)\n", avpkt->size);
> +        return AVERROR_INVALIDDATA;
> +    }
> +
> +    /* Basic sanity check, but not really harmful */
> +    if ((avpkt->data[0] != 0x73 && avpkt->data[0] != 0x72) ||
> +        avpkt->data[1] != 8) { // bpp probably
> +        av_log(avctx, AV_LOG_WARNING, "Unknown header 0x%02X%02X\n",
> +               avpkt->data[0], avpkt->data[1]);
> +    }
> +    keyframe = (avpkt->data[0] == 0x73);
> +
> +    /* Resize deflate buffer and frame on resolution change */
> +    if (ctx->deflatelen != avctx->width * avctx->height * 3) {
> +        ret = ff_get_buffer(avctx, ctx->current, 0);

Doesn't this leak current?

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to