diff options
author | John Stebbins <[email protected]> | 2016-12-14 13:59:59 -0800 |
---|---|---|
committer | John Stebbins <[email protected]> | 2016-12-14 13:59:59 -0800 |
commit | 701d4a8d3ed08e94c04cc02cf4c4d0afdc87eafe (patch) | |
tree | 16f60345bbf80edccb44f94b2ed83182f39d9641 /libhb | |
parent | c0bb5c4dd1476d975f872cbf0ab317bae6e1160f (diff) |
libhb: fix small leaks
fixes various context leaks in error conditions
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/decavcodec.c | 8 | ||||
-rw-r--r-- | libhb/scan.c | 6 | ||||
-rw-r--r-- | libhb/stream.c | 10 |
3 files changed, 22 insertions, 2 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index e021880b6..00dd95f4b 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -1049,6 +1049,7 @@ static int decodeFrame( hb_work_object_t *w, packet_info_t * packet_info ) { ++pv->decode_errors; } + av_free_packet(&avp); #ifdef USE_QSV if (pv->qsv.decode && pv->job->qsv.ctx == NULL && pv->video_codec_opened > 0) @@ -1466,7 +1467,7 @@ static int setup_extradata( hb_work_object_t *w, hb_buffer_t *in ) // of space to make vc1 work then associate the codec with the context. if (pv->context->extradata == NULL) { - if (pv->parser == NULL || pv->parser == NULL || + if (pv->parser == NULL || pv->parser->parser == NULL || pv->parser->parser->split == NULL) { return 0; @@ -1545,7 +1546,10 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in, return HB_WORK_DONE; } - pv->context = avcodec_alloc_context3( codec ); + if (pv->context == NULL) + { + pv->context = avcodec_alloc_context3( codec ); + } pv->context->workaround_bugs = FF_BUG_AUTODETECT; pv->context->err_recognition = AV_EF_CRCCHECK; pv->context->error_concealment = FF_EC_GUESS_MVS|FF_EC_DEBLOCK; diff --git a/libhb/scan.c b/libhb/scan.c index 384f5769a..76e173210 100644 --- a/libhb/scan.c +++ b/libhb/scan.c @@ -571,6 +571,7 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush ) hb_error("No video decoder set!"); free(info_list); crop_record_free(crops); + hb_stream_close(&stream); return 0; } hb_work_object_t *vid_decoder = hb_get_work(data->h, title->video_codec); @@ -582,6 +583,8 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush ) hb_error("Decoder init failed!"); free(info_list); crop_record_free(crops); + free( vid_decoder ); + hb_stream_close(&stream); return 0; } @@ -595,6 +598,9 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title, int flush ) { free( info_list ); crop_record_free( crops ); + vid_decoder->close( vid_decoder ); + free( vid_decoder ); + hb_stream_close(&stream); return 0; } if (data->bd) diff --git a/libhb/stream.c b/libhb/stream.c index cbddb4cfa..96813d35c 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -1006,6 +1006,11 @@ void hb_stream_close( hb_stream_t ** _d ) { hb_stream_t *stream = * _d; + if (stream == NULL) + { + return; + } + if ( stream->hb_stream_type == ffmpeg ) { ffmpeg_close( stream ); @@ -3974,6 +3979,7 @@ static int probe_dts_profile( hb_stream_t *stream, hb_pes_stream_t *pes ) break; default: + free(w); return 0; } const char *profile_name; @@ -3984,6 +3990,7 @@ static int probe_dts_profile( hb_stream_t *stream, hb_pes_stream_t *pes ) strncpy(pes->codec_name, profile_name, 80); pes->codec_name[79] = 0; } + free(w); return 1; } @@ -5026,6 +5033,7 @@ static int ffmpeg_open( hb_stream_t *stream, hb_title_t *title, int scan ) // and the other for reading. if ( avformat_open_input( &info_ic, stream->path, NULL, &av_opts ) < 0 ) { + av_dict_free( &av_opts ); return 0; } // libav populates av_opts with the things it didn't recognize. @@ -5079,6 +5087,8 @@ static int ffmpeg_open( hb_stream_t *stream, hb_title_t *title, int scan ) fail: if ( info_ic ) avformat_close_input( &info_ic ); + free(stream->ffmpeg_pkt); + stream->ffmpeg_pkt = NULL; return 0; } |