From abbb410ff269374e82241678d29b181fd331f1d3 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Thu, 14 Feb 2019 07:51:57 -0800 Subject: [PATCH] Fix assert in insertEntry(). The intent of the assert is to ensure that insertEntry() is not called with an empty entries array because that would cause you to get into a code path where the entry output parameter is not set. But the assert didn't correctly check that. Fix #635. --- src/vm/wren_value.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vm/wren_value.c b/src/vm/wren_value.c index f856cd91..40931920 100644 --- a/src/vm/wren_value.c +++ b/src/vm/wren_value.c @@ -519,6 +519,8 @@ static bool findEntry(MapEntry* entries, uint32_t capacity, Value key, static bool insertEntry(MapEntry* entries, uint32_t capacity, Value key, Value value) { + ASSERT(entries != NULL, "Should ensure capacity before inserting."); + MapEntry* entry; if (findEntry(entries, capacity, key, &entry)) { @@ -528,7 +530,6 @@ static bool insertEntry(MapEntry* entries, uint32_t capacity, } else { - ASSERT(entry != NULL, "Should ensure capacity before inserting."); entry->key = key; entry->value = value; return true;