From 657c7b548e931739042a944caee4fea185d04fe2 Mon Sep 17 00:00:00 2001 From: Ryan Patterson Date: Sun, 13 Oct 2024 10:17:12 +0800 Subject: [PATCH] Memory errors in wasm_store ``` In file included from tree_sitter/core/lib/src/lib.c:14: tree_sitter/core/lib/src/./wasm_store.c:868:94: warning: incompatible pointer types passing 'uint32_t *' (aka 'unsigned int *') to parameter of type 'uint64_t *' (aka 'unsigned long long *') [-Wincompatible-pointer-types] error = wasmtime_table_grow(context, &function_table, lexer_definitions_len, &initializer, &table_index); ^~~~~~~~~~~~ /Users/rpatterson/Projects/amel/py-tree-sitter/.direnv/python-3.11/include/wasmtime/table.h:105:31: note: passing argument to parameter 'prev_size' here uint64_t *prev_size); ^ In file included from tree_sitter/core/lib/src/lib.c:14: tree_sitter/core/lib/src/./wasm_store.c:969:102: warning: incompatible pointer types passing 'uint32_t *' (aka 'unsigned int *') to parameter of type 'uint64_t *' (aka 'unsigned long long *') [-Wincompatible-pointer-types] error = wasmtime_table_grow(context, &self->function_table, dylink_info->table_size, &initializer, &prev_table_size); ^~~~~~~~~~~~~~~~ /Users/rpatterson/Projects/amel/py-tree-sitter/.direnv/python-3.11/include/wasmtime/table.h:105:31: note: passing argument to parameter 'prev_size' here uint64_t *prev_size); ^ 2 warnings generated. ``` (cherry picked from commit 178c5d93f4ca8c962dc977365148148edbce1f24) --- lib/src/wasm_store.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/wasm_store.c b/lib/src/wasm_store.c index 81efbfcc..850d8405 100644 --- a/lib/src/wasm_store.c +++ b/lib/src/wasm_store.c @@ -864,7 +864,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) { // Add all of the lexer callback functions to the function table. Store their function table // indices on the in-memory lexer. - uint32_t table_index; + uint64_t table_index; error = wasmtime_table_grow(context, &function_table, lexer_definitions_len, &initializer, &table_index); if (error) { wasmtime_error_message(error, &message); @@ -965,7 +965,7 @@ static bool ts_wasm_store__instantiate( // Grow the function table to make room for the new functions. wasmtime_val_t initializer = {.kind = WASMTIME_FUNCREF}; - uint32_t prev_table_size; + uint64_t prev_table_size; error = wasmtime_table_grow(context, &self->function_table, dylink_info->table_size, &initializer, &prev_table_size); if (error) { format(error_message, "invalid function table size %u", dylink_info->table_size);