[FFmpeg-devel] [PATCH 3/6] tools/target_dem_fuzzer: Fix packet leak

James Almer jamrial at gmail.com
Mon Mar 22 23:19:02 EET 2021


On 3/22/2021 5:58 PM, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> ---
>   tools/target_dem_fuzzer.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/tools/target_dem_fuzzer.c b/tools/target_dem_fuzzer.c
> index af1840b359..90b7acefe2 100644
> --- a/tools/target_dem_fuzzer.c
> +++ b/tools/target_dem_fuzzer.c
> @@ -189,6 +189,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
>           av_freep(&fuzzed_pb->buffer);
>           av_freep(&fuzzed_pb);
>           avformat_free_context(avfmt);
> +        av_packet_free(&pkt);
>           return 0;
>       }

Assuming avformat_close_input() can be called on a AVFormatContext that 
failed to initialize, how about adding a fail label at the end and 
jumping there from here instead?

It would reduce code duplication and prevent the same mistake being done 
in the future if a new struct is allocated for whatever reason. It will 
also free fuzzed_pb with the correct function.


More information about the ffmpeg-devel mailing list