From d1009f498790e1c36200e4fff4135141b9928c00 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Wed, 16 Feb 2022 23:29:36 -0500 Subject: [PATCH] fix: flipped calloc args --- runtime/include/priority_queue.h | 5 ++--- runtime/src/sledge_abi.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/runtime/include/priority_queue.h b/runtime/include/priority_queue.h index bdf121d..0ca9e3d 100644 --- a/runtime/include/priority_queue.h +++ b/runtime/include/priority_queue.h @@ -273,9 +273,8 @@ priority_queue_initialize(size_t capacity, bool use_lock, priority_queue_get_pri /* Add one to capacity because this data structure ignores the element at 0 */ size_t one_based_capacity = capacity + 1; - struct priority_queue *priority_queue = (struct priority_queue *)calloc(sizeof(struct priority_queue) - + sizeof(void *) * one_based_capacity, - 1); + struct priority_queue *priority_queue = (struct priority_queue *) + calloc(1, sizeof(struct priority_queue) + sizeof(void *) * one_based_capacity); /* We're assuming a min-heap implementation, so set to larget possible value */ diff --git a/runtime/src/sledge_abi.c b/runtime/src/sledge_abi.c index da82e0c..59a2785 100644 --- a/runtime/src/sledge_abi.c +++ b/runtime/src/sledge_abi.c @@ -168,7 +168,7 @@ sledge_abi__wasi_snapshot_preview1_args_get(__wasi_size_t argv_retoffset, __wasi /* args_get backings return a vector of host pointers. We need a host buffer to store this * temporarily before unswizzling and writing to linear memory */ - char **argv_temp = calloc(sizeof(char *), argc); + char **argv_temp = calloc(argc, sizeof(char *)); if (unlikely(argv_temp == NULL)) { goto done; } /* Writes argv_buf to linear memory and argv vector to our temporary buffer */ @@ -284,7 +284,7 @@ sledge_abi__wasi_snapshot_preview1_environ_get(__wasi_size_t env_retoffset, __wa * these results to environ_temp temporarily before converting to offsets and writing to * linear memory. We could technically write this to linear memory and then do a "fix up," * but this would leak host information and constitue a security issue */ - char **env_temp = calloc(sizeof(char *), envc); + char **env_temp = calloc(envc, sizeof(char *)); if (unlikely(env_temp == NULL)) { goto done; } __wasi_size_t *env_retptr = (__wasi_size_t *)get_memory_ptr_for_runtime(env_retoffset,