On 2025-01-08 19:42 +0800, Jun Zhao wrote:
> From: Jun Zhao <mypopy...@gmail.com>
>
> close the input file if open output fail
>
> Signed-off-by: Jun Zhao <barryjz...@tencent.com>
> ---
>  ffbuild/bin2c.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/ffbuild/bin2c.c b/ffbuild/bin2c.c
> index dfeedd7669..168b0c658d 100644
> --- a/ffbuild/bin2c.c
> +++ b/ffbuild/bin2c.c
> @@ -38,8 +38,10 @@ int main(int argc, char **argv)
>          return -1;
>
>      output = fopen(argv[2], "wb");
> -    if (!output)
> +    if (!output) {
> +        fclose(input);
>          return -1;
> +    }
>
>      if (argc == 4) {
>          name = argv[3];

Not urgent because it's return from main. Anyway LGTM :)

There is another similar instance of this problem down at
the end of the function. Maybe you could also review/test
my attached patch and push on top.


Thanks,
  Alexander
From cd8d74d3eddb5ed447e8d59d2288ed1eb328f5e9 Mon Sep 17 00:00:00 2001
From: Alexander Strasser <eclip...@gmx.net>
Date: Sun, 12 Jan 2025 13:52:52 +0100
Subject: [PATCH] ffbuild/bin2c: Also close input stream in case of read errors

Signed-off-by: Alexander Strasser <eclip...@gmx.net>
---
 ffbuild/bin2c.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ffbuild/bin2c.c b/ffbuild/bin2c.c
index 168b0c658d..91f2d81e5b 100644
--- a/ffbuild/bin2c.c
+++ b/ffbuild/bin2c.c
@@ -69,8 +69,10 @@ int main(int argc, char **argv)

     fclose(output);

-    if (ferror(input) || !feof(input))
+    if (ferror(input) || !feof(input)) {
+        fclose(input);
         return -1;
+    }

     fclose(input);

--
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to