1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-21 09:44:49 +00:00

Try to remove potential overflow bugs.

Also make integer to size_t casts explicit rather than relying on
int32_t * sizeof(x) = size_t. This is kind of a personal preference for
this problem.
This commit is contained in:
Calvin Rose
2020-01-02 22:02:57 -06:00
parent a1cd759759
commit 6c7f376410
23 changed files with 82 additions and 72 deletions

View File

@@ -738,7 +738,7 @@ static JanetSignal run_vm(JanetFiber *fiber, Janet in, JanetFiberStatus status)
vm_assert(defindex < func->def->defs_length, "invalid funcdef");
fd = func->def->defs[defindex];
elen = fd->environments_length;
fn = janet_gcalloc(JANET_MEMORY_FUNCTION, sizeof(JanetFunction) + (elen * sizeof(JanetFuncEnv *)));
fn = janet_gcalloc(JANET_MEMORY_FUNCTION, sizeof(JanetFunction) + ((size_t) elen * sizeof(JanetFuncEnv *)));
fn->def = fd;
{
int32_t i;