[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix memory leaks and check for failure when calling .file
From: |
Dan Čermák |
Subject: |
Re: [PATCH] Fix memory leaks and check for failure when calling .file |
Date: |
Sun, 22 Dec 2019 09:46:12 +0100 |
Looks good to me to be pushed to master.
John Darrington <address@hidden> writes:
> ---
> ChangeLog | 5 +++++
> src/pk-file.c | 11 ++++++++++-
> 2 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 7fd81a1..346593b 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,8 @@
> +2019-12-21 John Darrington <address@hidden>
> +
> + * src/pk-file.c (pk_cmd_file): Fix memory leaks and
> + check for failures on opening file.
> +
> 2019-12-16 Dan Čermák <address@hidden>
>
> * src/pk-repl.c (pk_repl): fix memory leak of poke_history
> diff --git a/src/pk-file.c b/src/pk-file.c
> index caf6842..195bb00 100644
> --- a/src/pk-file.c
> +++ b/src/pk-file.c
> @@ -111,6 +111,7 @@ pk_cmd_file (int argc, struct pk_cmd_arg argv[], uint64_t
> uflags)
> {
> char *why = strerror (errno);
> pk_printf (_("%s: file cannot be read: %s\n"), arg_str, why);
> + free (filename);
> return 0;
> }
>
> @@ -121,10 +122,18 @@ pk_cmd_file (int argc, struct pk_cmd_arg argv[],
> uint64_t uflags)
> {
> printf (_("File %s already opened. Use `file #N' to switch.\n"),
> filename);
> + free (filename);
> return 0;
> }
>
> - ios_open (filename);
> + errno = 0;
> + if (IOS_ERROR == ios_open (filename))
> + {
> + pk_printf (_("Error opening %s: %s\n"), filename,
> + strerror (errno));
> + free (filename);
> + return 0;
> + }
> free (filename);
> }
>
> --
> 2.11.0
signature.asc
Description: PGP signature