Commit 58c8e14ddc for aom

commit 58c8e14ddc164068bcac81216b40165b50ad8f04
Author: James Zern <jzern@google.com>
Date:   Wed Jun 17 10:58:15 2026 -0700

    aomdec: fix FILE leak on failure

    * Reorder out file tty check before opening the input file
    * In `main_loop()` redirect to cleanup code to ensure `outfile` is
      closed on error.

    Fixes some clang-19 static analysis warnings.

    Bug: 474642915
    Change-Id: I22c23582a6ddc394d37effc75a3b56ea14a4feaa

diff --git a/apps/aomdec.c b/apps/aomdec.c
index e09ebfc8d0..4d5999f2c2 100644
--- a/apps/aomdec.c
+++ b/apps/aomdec.c
@@ -613,14 +613,6 @@ static int main_loop(int argc, const char **argv_) {
     fprintf(stderr, "No input file specified!\n");
     usage_exit();
   }
-
-  const bool using_file = strcmp(fn, "-") != 0;
-  /* Open file */
-  infile = using_file ? fopen(fn, "rb") : set_binary_mode(stdin);
-
-  if (!infile) {
-    fatal("Failed to open input file '%s'", using_file ? fn : "stdin");
-  }
 #if CONFIG_OS_SUPPORT
   /* Make sure we don't dump to the terminal, unless forced to with -o - */
   if (!outfile_pattern && isatty(STDOUT_FILENO) && !do_md5 && !noblit) {
@@ -631,6 +623,14 @@ static int main_loop(int argc, const char **argv_) {
     return EXIT_FAILURE;
   }
 #endif
+
+  const bool using_file = strcmp(fn, "-") != 0;
+  /* Open file */
+  infile = using_file ? fopen(fn, "rb") : set_binary_mode(stdin);
+
+  if (!infile) {
+    fatal("Failed to open input file '%s'", using_file ? fn : "stdin");
+  }
   input.aom_input_ctx->filename = fn;
   input.aom_input_ctx->file = infile;

@@ -689,7 +689,7 @@ static int main_loop(int argc, const char **argv_) {
         fprintf(stderr,
                 "Failed to guess framerate -- error parsing "
                 "webm file?\n");
-        return EXIT_FAILURE;
+        goto fail2;
       }
     }
 #endif