aboutsummaryrefslogtreecommitdiff
path: root/src/str.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2024-10-09 13:33:45 -0400
committerGitHub <noreply@github.com>2024-10-09 13:33:45 -0400
commit781f9873f20c45155e0dc3548bf47c74ab4a08fb (patch)
tree73d64f2b28a8742b2471b8549a81b1847f261edf /src/str.c
parent67dc983f124dd16c2e127fc5c9e4854e7bca9078 (diff)
parent8362f2c6150ec6e41a985764639d3d910e0da08c (diff)
downloadstasis-781f9873f20c45155e0dc3548bf47c74ab4a08fb.tar.gz
Merge pull request #59 from jhunkeler/leaks-and-squeaks
Leaks and squeaks
Diffstat (limited to 'src/str.c')
-rw-r--r--src/str.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/str.c b/src/str.c
index 56ea893..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,8 +196,9 @@ 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 if (tmp != argv) {
+ } else {
argv = tmp;
}
size += strlen(current) + separator_len;
@@ -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]);
}