From 9bccdc3dd3c473b6748cb5a93be7346c5c824cd4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 29 Apr 2026 12:41:28 -0400 Subject: handle asprintf errors --- src/lib/core/utils.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/core/utils.c b/src/lib/core/utils.c index f8fcadb..b4fd726 100644 --- a/src/lib/core/utils.c +++ b/src/lib/core/utils.c @@ -893,9 +893,15 @@ int env_manipulate_pathstr(const char *key, char *path, int mode) { char *system_path_new = NULL; if (mode & PM_APPEND) { - asprintf(&system_path_new, "%s%s%s", system_path_old, PATH_SEP, path); + if (asprintf(&system_path_new, "%s%s%s", system_path_old, PATH_SEP, path) < 0 || !system_path_new) { + SYSERROR("%s", "Unable to allocate memory to update PATH"); + return -1; + } } else if (mode & PM_PREPEND) { - asprintf(&system_path_new, "%s%s%s", path, PATH_SEP, system_path_old); + if (asprintf(&system_path_new, "%s%s%s", path, PATH_SEP, system_path_old) < 0 || !system_path_new) { + SYSERROR("%s", "Unable to allocate memory to update PATH"); + return -1; + } } if (!system_path_new) { -- cgit