From 2ae96a80fd103eaee27868faa3dfb1d2d857a56a Mon Sep 17 00:00:00 2001 From: John Arbuckle Date: Sun, 17 Dec 2023 19:34:37 -0500 Subject: [PATCH] Fix bug with size variable's value not being set when map is empty --- objc/type_convertion.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objc/type_convertion.m b/objc/type_convertion.m index 21f7ed79..2f3cd8b8 100644 --- a/objc/type_convertion.m +++ b/objc/type_convertion.m @@ -65,6 +65,7 @@ dict to_c_items(void* ptr) { dict c_dict; NSArray * keys = [result_ allKeys]; int size = [keys count]; + c_dict.len = size; if (size > 0) { void** key_data = malloc(size * sizeof(void*)); void** value_data = malloc(size * sizeof(void*)); @@ -76,7 +77,6 @@ dict to_c_items(void* ptr) { } c_dict.key_data = key_data; c_dict.value_data = value_data; - c_dict.len = size; } return c_dict; }