From 5b9324916df329c913913896c9ac8da81bcc4c2d Mon Sep 17 00:00:00 2001 From: vms Date: Fri, 3 Sep 2021 13:49:23 +0300 Subject: [PATCH] fix BWU compatibility --- sqlite3.wit | 5 +++++ src/wrapper.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sqlite3.wit b/sqlite3.wit index ef9c828..bf3d9c7 100644 --- a/sqlite3.wit +++ b/sqlite3.wit @@ -231,6 +231,7 @@ (@interface func (type 19) arg.get 0 string.size + i32.push 1 call-core 0 arg.get 0 string.lower_memory @@ -238,6 +239,7 @@ i32.from_s32 arg.get 2 string.size + i32.push 1 call-core 0 arg.get 2 string.lower_memory @@ -307,6 +309,7 @@ i32.from_u32 arg.get 1 string.size + i32.push 1 call-core 0 arg.get 1 string.lower_memory @@ -349,6 +352,7 @@ i32.from_s32 arg.get 2 string.size + i32.push 1 call-core 0 arg.get 2 string.lower_memory @@ -366,6 +370,7 @@ i32.from_u32 arg.get 1 string.size + i32.push 1 call-core 0 arg.get 1 string.lower_memory diff --git a/src/wrapper.c b/src/wrapper.c index 65f0d12..0b17f75 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -8,7 +8,11 @@ int RESULT_SIZE; cvector_vector_type(void *) OBJECTS_TO_RELEASE; -void* allocate(size_t size) { +void* allocate(size_t size, size_t _type_tag) { + if (size == 0 || size + 1 == 0) { + return 0; + } + // this +1 is needed to append then zero byte to strings passing to this module. return malloc(size + 1); }