aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2026-04-26 01:49:48 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2026-04-26 01:49:48 -0400
commitf4bccc6b21c8eec58bb08bc22115a93a2352868d (patch)
tree71bda1e5db6b08649750d7e9fc4f8ee8c9f48510
parent917df9195011c852a6efffd4f1dc40ff007534c9 (diff)
downloadstasis-f4bccc6b21c8eec58bb08bc22115a93a2352868d.tar.gz
Add allocation checksbughunt-1001
-rw-r--r--src/cli/stasis_indexer/stasis_indexer_main.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cli/stasis_indexer/stasis_indexer_main.c b/src/cli/stasis_indexer/stasis_indexer_main.c
index d71c341..ed938b7 100644
--- a/src/cli/stasis_indexer/stasis_indexer_main.c
+++ b/src/cli/stasis_indexer/stasis_indexer_main.c
@@ -212,6 +212,10 @@ int main(const int argc, char *argv[]) {
if (optind < argc) {
rootdirs_total = argc - current_index;
rootdirs = calloc(rootdirs_total + 1, sizeof(*rootdirs));
+ if (!rootdirs) {
+ SYSERROR("%s", "unable to allocate memory for rootdirs array");
+ exit(1);
+ }
int i = 0;
while (optind < argc) {
@@ -223,6 +227,10 @@ int main(const int argc, char *argv[]) {
}
// use first positional argument
rootdirs[i] = realpath(argv[optind], NULL);
+ if (!rootdirs[i]) {
+ SYSERROR("%s", "Unable to allocate memory for root directory");
+ exit(1);
+ }
optind++;
break;
}