[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] Check return value of pk_str_concat
From: |
Tim Rühsen |
Subject: |
Re: [PATCH 1/2] Check return value of pk_str_concat |
Date: |
Wed, 6 May 2020 17:16:58 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
Something is wrong with the ICE stuff... sorry
On 06.05.20 17:11, Tim Rühsen wrote:
> 2020-05-06 Tim Rühsen <address@hidden>
>
> * libpoke/pkl-fold.c (OP_BINARY_SSS): Check return value of
> pk_str_concat.
> * libpoke/pkl.c (pkl_new): Likewise.
> * poke/pk-cmd.c (pk_cmd_exec): Likewise.
> * poke/poke.c (initialize_user): Likewise.
> ---
> ChangeLog | 8 ++++++++
> libpoke/pkl-fold.c | 2 ++
> libpoke/pkl.c | 12 ++++++++++++
> poke/pk-cmd.c | 7 +++++++
> poke/poke.c | 15 +++++++++++++++
> 5 files changed, 44 insertions(+)
>
> diff --git a/libpoke/pkl-fold.c b/libpoke/pkl-fold.c
> index 64feffdb..30f4b45c 100644
> --- a/libpoke/pkl-fold.c
> +++ b/libpoke/pkl-fold.c
> @@ -586,6 +586,8 @@ EMUL_UU (bnoto) { return ~op; }
> \
> res = pk_str_concat (PKL_AST_STRING_POINTER (op1), \
> PKL_AST_STRING_POINTER (op2), NULL); \
> + if (!res) \
> + PKL_PASS_ICE; \
> \
> new = pkl_ast_make_string (PKL_PASS_AST, res); \
> free (res); \
> diff --git a/libpoke/pkl.c b/libpoke/pkl.c
> index 3b6ae369..aeb6ecc9 100644
> --- a/libpoke/pkl.c
> +++ b/libpoke/pkl.c
> @@ -79,6 +79,16 @@ pkl_new (pvm vm, const char *rt_path)
> error and should be reported as such. */
> {
> char *poke_rt_pk = pk_str_concat (rt_path, "/pkl-rt.pk", NULL);
> + if (!poke_rt_pk)
> + {
> +out_of_memory:
> + pk_term_class ("error");
> + pk_puts ("error: ");
> + pk_term_end_class ("error");
> + pk_puts ("out of memory\n");
> +
> + return NULL;
> + }
>
> if (!pkl_compile_file (compiler, poke_rt_pk))
> {
> @@ -97,6 +107,8 @@ pkl_new (pvm vm, const char *rt_path)
> /* Load the standard library. */
> {
> char *poke_std_pk = pk_str_concat (rt_path, "/std.pk", NULL);
> + if (!poke_std_pk)
> + goto out_of_memory;
>
> if (!pkl_compile_file (compiler, poke_std_pk))
> return NULL;
> diff --git a/poke/pk-cmd.c b/poke/pk-cmd.c
> index b57f0ac0..6fb9f3f9 100644
> --- a/poke/pk-cmd.c
> +++ b/poke/pk-cmd.c
> @@ -585,6 +585,13 @@ pk_cmd_exec (const char *str)
> what = 1;
>
> cmd_alloc = pk_str_concat (cmd, ";", NULL);
> + if (!cmd_alloc)
> + {
> + pk_printf (_("out of memory\n"));
> + retval = 0;
> + goto cleanup;
> + }
> +
> ecmd = cmd_alloc;
> }
>
> diff --git a/poke/poke.c b/poke/poke.c
> index f6d46351..798adb2b 100644
> --- a/poke/poke.c
> +++ b/poke/poke.c
> @@ -446,6 +446,11 @@ initialize_user (void)
> if (homedir != NULL)
> {
> char *pokerc = pk_str_concat (homedir, "/.pokerc", NULL);
> + if (!pokerc)
> + {
> + pk_printf (_("out of memory\n"));
> + exit (EXIT_FAILURE);
> + }
>
> if (pk_file_readable (pokerc) == NULL)
> {
> @@ -479,6 +484,11 @@ initialize_user (void)
> xdg_config_dirs = "/etc/xdg";
>
> char *config_path = pk_str_concat (xdg_config_dirs, ":",
> xdg_config_home, NULL);
> + if (!config_path)
> + {
> + pk_printf (_("out of memory\n"));
> + exit (EXIT_FAILURE);
> + }
>
> char *dir = strtok (config_path, ":");
> do
> @@ -490,6 +500,11 @@ initialize_user (void)
> /* Mount the full path and determine whether the resulting
> file is readable. */
> char *config_filename = pk_str_concat (dir, "/poke/pokerc.conf",
> NULL);
> + if (!config_path)
> + {
> + pk_printf (_("out of memory\n"));
> + exit (EXIT_FAILURE);
> + }
>
> if (pk_file_readable (config_filename) == NULL)
> {
> --
> 2.26.2
>
signature.asc
Description: OpenPGP digital signature