vhook/watermark.c:116: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned32 by call to `get_watermark_picture`.

vhook/watermark.c:116:9: Call
114. 
115.     if (ci) {
116.         get_watermark_picture(ci, 1);
             ^
117.         sws_freeContext(ci->toRGB_convert_ctx);
118.         sws_freeContext(ci->watermark_convert_ctx);

vhook/watermark.c:454:1: Parameter `ci->pFormatCtx->nb_programs`
  452.  * 0 = ok, -1 = error
  453.  ****************************************************************************/
  454. int get_watermark_picture(ContextInfo *ci, int cleanup)
       ^
  455. {
  456.     if (1 == ci->is_done && 0 == cleanup) return 0;

vhook/watermark.c:645:13: Call
  643.         // Close the video file
  644.         if (0 != ci->pFormatCtx) {
  645.             av_close_input_file(ci->pFormatCtx);
                   ^
  646.             ci->pFormatCtx = 0;
  647.         }

libavformat/utils.c:2152:1: Parameter `s->nb_programs`
    2150. }
    2151. 
    2152. void av_close_input_file(AVFormatContext *s)
          ^
    2153. {
    2154.     ByteIOContext *pb = s->iformat->flags & AVFMT_NOFILE ? NULL : s->pb;

libavformat/utils.c:2155:5: Call
    2153. {
    2154.     ByteIOContext *pb = s->iformat->flags & AVFMT_NOFILE ? NULL : s->pb;
    2155.     av_close_input_stream(s);
              ^
    2156.     if (pb)
    2157.         url_fclose(pb);

libavformat/utils.c:2118:1: <LHS trace>
2116. }
2117. 
2118. void av_close_input_stream(AVFormatContext *s)
      ^
2119. {
2120.     int i;

libavformat/utils.c:2118:1: Parameter `s->nb_programs`
      2116. }
      2117. 
      2118. void av_close_input_stream(AVFormatContext *s)
            ^
      2119. {
      2120.     int i;

libavformat/utils.c:2141:9: Binary operation: ([0, +oo] - 1):unsigned32 by call to `get_watermark_picture` 
      2139.         av_free(st);
      2140.     }
      2141.     for(i=s->nb_programs-1; i>=0; i--) {
                    ^
      2142.         av_freep(&s->programs[i]->provider_name);
      2143.         av_freep(&s->programs[i]->name);

void av_close_input_stream(AVFormatContext *s)
{
    int i;
    AVStream *st;
    if (s->cur_st && s->cur_st->parser)
        av_free_packet(&s->cur_pkt);
    if (s->iformat->read_close)
        s->iformat->read_close(s);
    for(i=0;i<s->nb_streams;i++) {
        st = s->streams[i];
        if (st->parser) {
            av_parser_close(st->parser);
        }
        av_free(st->index_entries);
        av_free(st->codec->extradata);
        av_free(st->codec);
        av_free(st->filename);
        av_free(st);
    }
    for(i=s->nb_programs-1; i>=0; i--) {
        av_freep(&s->programs[i]->provider_name);
        av_freep(&s->programs[i]->name);
        av_freep(&s->programs[i]->stream_index);
        av_freep(&s->programs[i]);
    }
    flush_packet_queue(s);
    av_freep(&s->priv_data);
    av_free(s);
}
['void Release(void *ctx)\n{\n    ContextInfo *ci;\n    ci = (ContextInfo *) ctx;\n    if (ci) {\n        get_watermark_picture(ci, 1);\n        sws_freeContext(ci->toRGB_convert_ctx);\n        sws_freeContext(ci->watermark_convert_ctx);\n        sws_freeContext(ci->fromRGB_convert_ctx);\n    }\n    av_free(ctx);\n}', 'int get_watermark_picture(ContextInfo *ci, int cleanup)\n{\n    if (1 == ci->is_done && 0 == cleanup) return 0;\n    if (0 == ci->pFrameRGB &&\n        0 == cleanup)\n    {\n        if (av_open_input_file(&ci->pFormatCtx, ci->filename, NULL, 0, NULL) != 0) {\n            ci->i = strlen(ci->filename);\n            if (0 == ci->i) {\n                av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() No filename to watermark vhook\\n");\n                return -1;\n            }\n            while (ci->i > 0) {\n                if (ci->filename[ci->i] == \'.\') {\n                    ci->i++;\n                    break;\n                }\n                ci->i--;\n            }\n               ci->p_ext = &(ci->filename[ci->i]);\n            ci->file_iformat = av_find_input_format (ci->p_ext);\n            if (0 == ci->file_iformat) {\n                av_log(NULL, AV_LOG_INFO, "get_watermark_picture() attempt to use image2 for [%s]\\n", ci->p_ext);\n                ci->file_iformat = av_find_input_format ("image2");\n            }\n            if (0 == ci->file_iformat) {\n                av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Really failed to find iformat [%s]\\n", ci->p_ext);\n                return -1;\n            }\n            if (av_open_input_file(&ci->pFormatCtx, ci->filename, ci->file_iformat, 0, NULL)!=0) {\n                av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to open input file [%s]\\n", ci->filename);\n                return -1;\n            }\n        }\n        if(av_find_stream_info(ci->pFormatCtx)<0) {\n            av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to find stream info\\n");\n            return -1;\n        }\n        ci->videoStream=-1;\n        for(ci->i = 0; ci->i < ci->pFormatCtx->nb_streams; ci->i++)\n            if(ci->pFormatCtx->streams[ci->i]->codec->codec_type==CODEC_TYPE_VIDEO)\n            {\n                ci->videoStream = ci->i;\n                break;\n            }\n        if(ci->videoStream == -1) {\n            av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to find any video stream\\n");\n            return -1;\n        }\n        ci->st = ci->pFormatCtx->streams[ci->videoStream];\n        ci->x_size = ci->st->codec->width;\n        ci->y_size = ci->st->codec->height;\n        ci->pCodecCtx = ci->pFormatCtx->streams[ci->videoStream]->codec;\n        ci->pCodec = avcodec_find_decoder(ci->pCodecCtx->codec_id);\n        if(ci->pCodec == NULL) {\n            av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to find any codec\\n");\n            return -1;\n        }\n        if(avcodec_open(ci->pCodecCtx, ci->pCodec)<0) {\n            av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to open codec\\n");\n            return -1;\n        }\n        if (ci->pCodecCtx->time_base.den>1000 && ci->pCodecCtx->time_base.num==1)\n            ci->pCodecCtx->time_base.num=1000;\n        ci->pFrame = avcodec_alloc_frame();\n        ci->pFrameRGB=avcodec_alloc_frame();\n        if(ci->pFrameRGB==NULL) {\n            av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to alloc pFrameRGB\\n");\n            return -1;\n        }\n        ci->numBytes = avpicture_get_size(PIX_FMT_RGB32, ci->pCodecCtx->width,\n            ci->pCodecCtx->height);\n        ci->buffer = av_malloc(ci->numBytes);\n        avpicture_fill((AVPicture *)ci->pFrameRGB, ci->buffer, PIX_FMT_RGB32,\n            ci->pCodecCtx->width, ci->pCodecCtx->height);\n    }\n    if (0 == cleanup)\n    {\n        while(av_read_frame(ci->pFormatCtx, &ci->packet)>=0)\n        {\n            if(ci->packet.stream_index == ci->videoStream)\n            {\n                avcodec_decode_video(ci->pCodecCtx, ci->pFrame, &ci->frameFinished,\n                    ci->packet.data, ci->packet.size);\n                if(ci->frameFinished)\n                {\n                    ci->watermark_convert_ctx =\n                        sws_getCachedContext(ci->watermark_convert_ctx,\n                            ci->pCodecCtx->width, ci->pCodecCtx->height, ci->pCodecCtx->pix_fmt,\n                            ci->pCodecCtx->width, ci->pCodecCtx->height, PIX_FMT_RGB32,\n                            sws_flags, NULL, NULL, NULL);\n                    if (ci->watermark_convert_ctx == NULL) {\n                        av_log(NULL, AV_LOG_ERROR,\n                              "Cannot initialize the watermark conversion context\\n");\n                        return -1;\n                    }\n                    sws_scale(ci->watermark_convert_ctx,\n                             ci->pFrame->data, ci->pFrame->linesize, 0, ci->pCodecCtx->height,\n                             ci->pFrameRGB->data, ci->pFrameRGB->linesize);\n                    return 0;\n                }\n            }\n            av_free_packet(&ci->packet);\n        }\n        ci->is_done = 1;\n        return 0;\n    }\n    if (0 != cleanup)\n    {\n        av_freep(&ci->buffer);\n        av_freep(&ci->pFrameRGB);\n        if (0 != ci->pCodecCtx) {\n            avcodec_close(ci->pCodecCtx);\n            ci->pCodecCtx = 0;\n        }\n        if (0 != ci->pFormatCtx) {\n            av_close_input_file(ci->pFormatCtx);\n            ci->pFormatCtx = 0;\n        }\n        ci->is_done = 0;\n    }\n    return 0;\n}', 'void av_close_input_file(AVFormatContext *s)\n{\n    ByteIOContext *pb = s->iformat->flags & AVFMT_NOFILE ? NULL : s->pb;\n    av_close_input_stream(s);\n    if (pb)\n        url_fclose(pb);\n}', 'void av_close_input_stream(AVFormatContext *s)\n{\n    int i;\n    AVStream *st;\n    if (s->cur_st && s->cur_st->parser)\n        av_free_packet(&s->cur_pkt);\n    if (s->iformat->read_close)\n        s->iformat->read_close(s);\n    for(i=0;i<s->nb_streams;i++) {\n        st = s->streams[i];\n        if (st->parser) {\n            av_parser_close(st->parser);\n        }\n        av_free(st->index_entries);\n        av_free(st->codec->extradata);\n        av_free(st->codec);\n        av_free(st->filename);\n        av_free(st);\n    }\n    for(i=s->nb_programs-1; i>=0; i--) {\n        av_freep(&s->programs[i]->provider_name);\n        av_freep(&s->programs[i]->name);\n        av_freep(&s->programs[i]->stream_index);\n        av_freep(&s->programs[i]);\n    }\n    flush_packet_queue(s);\n    av_freep(&s->priv_data);\n    av_free(s);\n}']