From c6439cc574fdabbc27ce5031317fefcb68f29601 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 5 Nov 2024 10:51:48 +0800 Subject: [PATCH] Revert wasmSpineExtension.cpp, return nullptr if size is zero. --- .../editor-support/spine-wasm/wasmSpineExtension.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/native/cocos/editor-support/spine-wasm/wasmSpineExtension.cpp b/native/cocos/editor-support/spine-wasm/wasmSpineExtension.cpp index 0c2c78b83b9..068716e354b 100644 --- a/native/cocos/editor-support/spine-wasm/wasmSpineExtension.cpp +++ b/native/cocos/editor-support/spine-wasm/wasmSpineExtension.cpp @@ -30,18 +30,27 @@ char *WasmSpineExtension::_readFile(const String &path, int *length) { void *WasmSpineExtension::_alloc(size_t size, const char *file, int line) { SP_UNUSED(file); SP_UNUSED(line); + if (size == 0) { + return nullptr; + } return ::malloc(sizeof(uint8_t) * size); } void *WasmSpineExtension::_calloc(size_t size, const char *file, int line) { SP_UNUSED(file); SP_UNUSED(line); + if (size == 0) { + return nullptr; + } return ::calloc(1, size); } void *WasmSpineExtension::_realloc(void *ptr, size_t size, const char *file, int line) { SP_UNUSED(file); SP_UNUSED(line); + if (size == 0) { + return nullptr; + } return ::realloc(ptr, sizeof(uint8_t) * size); }