From: Fabian Keil <fk@fabiankeil.de>
Date: Wed, 28 Sep 2022 06:06:14 +0000 (+0200)
Subject: make_path: Use malloc_or_die()
X-Git-Tag: v_3_0_34~60
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/user-manual/developer-manual/@default-cgi@toggle?a=commitdiff_plain;h=f87573e378e440c0f0aba367e04928f7da8aafae;p=privoxy.git

make_path: Use malloc_or_die()

... in cases where allocation errors were already fatal anyway.
---

diff --git a/miscutil.c b/miscutil.c
index fe0cd9b5..e6532049 100644
--- a/miscutil.c
+++ b/miscutil.c
@@ -700,8 +700,7 @@ char * make_path(const char * dir, const char * file)
           * Relative path, so start with the base directory.
           */
          path_size += strlen(basedir) + 1; /* +1 for the slash */
-         path = malloc(path_size);
-         if (!path) log_error(LOG_LEVEL_FATAL, "malloc failed!");
+         path = malloc_or_die(path_size);
          strlcpy(path, basedir, path_size);
          strlcat(path, "/", path_size);
          strlcat(path, dir, path_size);
@@ -709,8 +708,7 @@ char * make_path(const char * dir, const char * file)
       else
 #endif /* defined unix */
       {
-         path = malloc(path_size);
-         if (!path) log_error(LOG_LEVEL_FATAL, "malloc failed!");
+         path = malloc_or_die(path_size);
          strlcpy(path, dir, path_size);
       }