diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-29 12:41:28 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-29 12:41:28 -0400 |
| commit | 9bccdc3dd3c473b6748cb5a93be7346c5c824cd4 (patch) | |
| tree | 3a718702cd530a1a864d5744f2e34515d81f3adf /src/lib | |
| parent | 3ad06f7dc738940ee31a21e3b95c0f3d3b8dbd6f (diff) | |
| download | stasis-9bccdc3dd3c473b6748cb5a93be7346c5c824cd4.tar.gz | |
handle asprintf errors
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/core/utils.c | 10 |
1 files changed, 8 insertions, 2 deletions
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) { |
