[FFmpeg-devel] [PATCH] examples: Replace with proper error handling to avoid potential memory errors
Alexander Strasser
eclipse7 at gmx.net
Wed Aug 6 11:11:51 EEST 2025
On 2025-08-05 22:18 +0200, Nicolas George wrote:
> Jiasheng Jiang (HE12025-08-05):
> > Moreover, replace with proper error handling to avoid potential memory leak.
>
> There is no potential memory leak with exit().
>
> And it does not have to be a lesson in good C practices.
I'm a bit undecided about this; especially because these are example files.
Best would be to have them correct, small, and beautiful while still
promoting good C practices.
I agree that the patch as proposed is not an improvement over all.
I would say it would be best to shorten it to only the first change:
--- a/doc/examples/decode_audio.c
+++ b/doc/examples/decode_audio.c
@@ -128,41 +128,48 @@ int main(int argc, char **argv)
outfilename = argv[2];
pkt = av_packet_alloc();
+ if (!pkt)
+ exit(1);
If someone wants to improve the example files to better handle errors
and resource de-allocation for real world use cases, then it should be
a follow up submission.
Best regards,
Alexander
More information about the ffmpeg-devel
mailing list