kbx: Close file handle when return.

* kbx/keybox-dump.c (_keybox_dump_find_dups): Close FP on the error
paths.

--

GnuPG-bug-id: 6495
Signed-off-by: zhangguangzhi <zhangguangzhi3@huawei.com>
This commit is contained in:
zhangguangzhi 2023-05-18 20:24:41 +08:00 committed by NIIBE Yutaka
parent 40090dbbf9
commit 06aeb2b45c
No known key found for this signature in database
GPG Key ID: 640114AF89DE6054
1 changed files with 4 additions and 0 deletions

View File

@ -810,6 +810,8 @@ _keybox_dump_find_dups (const char *filename, int print_them, FILE *outfp)
gpg_error_t tmperr = gpg_error_from_syserror ();
fprintf (outfp, "error allocating array for '%s': %s\n",
filename, strerror(errno));
if (fp != es_stdin)
es_fclose (fp);
return tmperr;
}
dupitems_count = 0;
@ -834,6 +836,8 @@ _keybox_dump_find_dups (const char *filename, int print_them, FILE *outfp)
fprintf (outfp, "error reallocating array for '%s': %s\n",
filename, strerror(errno));
free (dupitems);
if (fp != es_stdin)
es_fclose (fp);
return tmperr;
}
dupitems = tmp;