diff --git a/Dockerfile b/Dockerfile index ca62905a..1f78a56d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,7 @@ RUN apt-get update \ make \ cargo -RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-10/wasi-sdk-10.0-linux.tar.gz | tar xz --strip-components=1 -C / -RUN cargo install fcli +RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/wasi-sdk-11.0-linux.tar.gz | tar xz --strip-components=1 -C / VOLUME /code WORKDIR /code diff --git a/src/wrapper.c b/src/wrapper.c index 264cfe95..a91190d6 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -18,9 +18,13 @@ void init() { int g_isInited = 0; -void* allocate(size_t size) { - // allocate one more byte for adding the \n symbol that indicated the end of request - return zmalloc(size + 1); +void* allocate(size_t size, size_t _type_tag) { + if (size == 0 || size + 1 == 0) { + return 0; + } + + // allocate one more byte for adding the \n symbol that indicated the end of request + return zmalloc(size + 1); } void deallocate(void *ptr, int size) { @@ -75,7 +79,7 @@ void clean_client_buffer(client *c) { } char *write_response(client *c, size_t *response_size) { - char *response = allocate(c->bufpos + c->reply_bytes); + char *response = allocate(c->bufpos + c->reply_bytes, 1); *response_size = 0; memcpy(response, c->buf, c->bufpos);