Memory leak in Sprite::setCenterRectNormalized

Hi,

I found memory leak while called

Scale9Sprite* Scale9Sprite::create(const std::string& fileaname)

in function

void Sprite::setCenterRectNormalized(const cocos2d::Rect &rectTopLeft)

please add

CC_SAFE_FREE(_trianglesVertex);
CC_SAFE_FREE(_trianglesIndex);

BEFORE

// 9 quads + 7 exterior points = 16
_trianglesVertex = (V3F_C4B_T2F*) malloc(sizeof(_trianglesVertex) * (9 + 3 + 4));
// 9 quads, each needs 6 vertices = 54
_trianglesIndex = (unsigned short
) malloc(sizeof(*_trianglesIndex) * 6 * 9);

Thanks :slight_smile:

Vladislav

I think, that an issue + pull request would be more helpful.

1 Like