From b8a022238f01799c6a6ce9cb8c0f629184e339d8 Mon Sep 17 00:00:00 2001 From: ffskyfan Date: Fri, 5 Jun 2015 12:14:27 +0800 Subject: [PATCH] Update extension.h #define MALLOC(TYPE,COUNT) ((TYPE*)_malloc(sizeof(TYPE) * COUNT, __FILE__, __LINE__)) It is a really dangerous macros here. If use it like this "MALLOC(Type, n+2)", it will alloc sizeof(TYPE) * COUNT + 2 byte memory.but I want it alloc sizeof(TYPE) * (COUNT + 2) byte. It is a typical macro unwind error. --- cocos/editor-support/spine/extension.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/editor-support/spine/extension.h b/cocos/editor-support/spine/extension.h index 281d632123..c33e14664e 100644 --- a/cocos/editor-support/spine/extension.h +++ b/cocos/editor-support/spine/extension.h @@ -32,7 +32,7 @@ #define SPINE_EXTENSION_H_ /* All allocation uses these. */ -#define MALLOC(TYPE,COUNT) ((TYPE*)_malloc(sizeof(TYPE) * COUNT, __FILE__, __LINE__)) +#define MALLOC(TYPE,COUNT) ((TYPE*)_malloc(sizeof(TYPE) * (COUNT), __FILE__, __LINE__)) #define CALLOC(TYPE,COUNT) ((TYPE*)_calloc(COUNT, sizeof(TYPE), __FILE__, __LINE__)) #define NEW(TYPE) CALLOC(TYPE,1)