aboutsummaryrefslogtreecommitdiff
path: root/src/lib/delivery/delivery_init.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2026-05-12 13:34:13 -0400
committerGitHub <noreply@github.com>2026-05-12 13:34:13 -0400
commitd8ee8c27444a56bb98dd8bd67a019a1e9efbcc10 (patch)
tree6ae1275a5f8e5794b917aac95c6cb1ab3f4cb6c5 /src/lib/delivery/delivery_init.c
parent4649a889a916aa377ebd3ca8f3daa9ac703baa34 (diff)
parent1d91efc28e30c8501428fec8ff6cd7b13dcdfb95 (diff)
downloadstasis-1.6.1.tar.gz
Merge pull request #139 from jhunkeler/bughunt-1002HEAD1.6.1master
Bughunt 0x1002
Diffstat (limited to 'src/lib/delivery/delivery_init.c')
-rw-r--r--src/lib/delivery/delivery_init.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/lib/delivery/delivery_init.c b/src/lib/delivery/delivery_init.c
index c73e7f0..5bc326d 100644
--- a/src/lib/delivery/delivery_init.c
+++ b/src/lib/delivery/delivery_init.c
@@ -201,11 +201,18 @@ int delivery_init_platform(struct Delivery *ctx) {
}
for (size_t i = 0; i < DELIVERY_PLATFORM_MAX; i++) {
ctx->system.platform[i] = calloc(DELIVERY_PLATFORM_MAXLEN, sizeof(*ctx->system.platform[0]));
+ if (!ctx->system.platform[i]) {
+ SYSERROR("Unable to allocate record %zu in platform array", i);
+ guard_array_n_free(ctx->system.platform, i);
+ return -1;
+ }
}
ctx->system.arch = strdup(uts.machine);
if (!ctx->system.arch) {
// memory error
+ guard_array_n_free(ctx->system.platform, DELIVERY_PLATFORM_MAX);
+ ctx->system.platform = NULL;
return -1;
}
@@ -218,6 +225,8 @@ int delivery_init_platform(struct Delivery *ctx) {
SYSDEBUG("Setting platform");
strncpy(ctx->system.platform[DELIVERY_PLATFORM], uts.sysname, DELIVERY_PLATFORM_MAXLEN - 1);
+ ctx->system.platform[DELIVERY_PLATFORM][DELIVERY_PLATFORM_MAXLEN - 1] = '\0';
+
if (!strcmp(ctx->system.platform[DELIVERY_PLATFORM], "Darwin")) {
snprintf(ctx->system.platform[DELIVERY_PLATFORM_CONDA_SUBDIR], DELIVERY_PLATFORM_MAXLEN, "osx-%s", archsuffix);
strncpy(ctx->system.platform[DELIVERY_PLATFORM_CONDA_INSTALLER], "MacOSX", DELIVERY_PLATFORM_MAXLEN - 1);
@@ -290,7 +299,10 @@ int delivery_init(struct Delivery *ctx, int render_mode) {
}
// Configure architecture and platform information
- delivery_init_platform(ctx);
+ if (delivery_init_platform(ctx)) {
+ // memory error
+ return -1;
+ }
// Create STASIS directory structure
delivery_init_dirs_stage1(ctx);