[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] Check return value of pk_str_concat
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH 1/2] Check return value of pk_str_concat |
Date: |
Thu, 07 May 2020 11:20:43 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hi Tim.
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)
{
What about having a function defined in poke/poke.c, like
poke_out_of_memory, that would take care of emitting the diagnostic
message and then exit with EXIT_FAILURE?