diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-06-04 13:17:31 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-06-04 13:17:31 -0400 |
| commit | 4a7a44eccbb7c2096f3bfc00c27c7ccadc028aba (patch) | |
| tree | 3f4f4a55d79a5821587fe9016ec52e8cd74b99d2 /src | |
| parent | a4eff2558e67f8ef405b561dcec260f9b41430a7 (diff) | |
| download | stasis-4a7a44eccbb7c2096f3bfc00c27c7ccadc028aba.tar.gz | |
join_ex: Fix leak on memory error
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/core/str.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/core/str.c b/src/lib/core/str.c index a04293f..400c93c 100644 --- a/src/lib/core/str.c +++ b/src/lib/core/str.c @@ -225,6 +225,11 @@ char *join_ex(char *separator, ...) { // Generate output string result = calloc(size + 1, sizeof(char)); + if (!result) { + guard_array_free_by_count(argv, argc); + return NULL; + } + for (size_t i = 0; i < argc; i++) { // Append argument to string safe_strncat(result, argv[i], size + 1); // no -1 because +1 above |
