aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-10-09 11:00:28 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-10-09 12:51:30 -0400
commit09e8910d66ed566bb0224f68726a057cc47aa0c0 (patch)
treef71006bc0855794edc40604208488d9294358300
parent43df8ff3ac4156b99d1e288d666ea1a77584b3f8 (diff)
downloadstasis-09e8910d66ed566bb0224f68726a057cc47aa0c0.tar.gz
str.c: fix leak
-rw-r--r--src/str.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/str.c b/src/str.c
index 9f63c72..868a6c7 100644
--- a/src/str.c
+++ b/src/str.c
@@ -175,7 +175,7 @@ char *join_ex(char *separator, ...) {
}
// Initialize array
- argv = calloc(argc + 1, sizeof(char *));
+ argv = calloc(argc + 1, sizeof(char **));
if (argv == NULL) {
perror("join_ex calloc failed");
return NULL;
@@ -196,6 +196,7 @@ char *join_ex(char *separator, ...) {
char **tmp = realloc(argv, (argc + 1) * sizeof(char *));
if (tmp == NULL) {
perror("join_ex realloc failed");
+ guard_free(argv);
return NULL;
} else {
argv = tmp;
@@ -583,7 +584,7 @@ char **strdup_array(char **array) {
for (elems = 0; array[elems] != NULL; elems++);
// Create new array
- result = calloc(elems + 1, sizeof(result));
+ result = calloc(elems + 1, sizeof(*result));
for (size_t i = 0; i < elems; i++) {
result[i] = strdup(array[i]);
}