Skip to content

A Memory Corruption Bug due to initWithObjects in CCArray #3353

@mywcyfl

Description

@mywcyfl

It seems exist a bug in the function initWithObjects of the class CCArray,the file is"CCArray.cpp",line 157.The edition of Cocos2d-x is "cocos2d-x-2.1.4".
Bug Description:
It calls the "ccArrayFree()" in the first statement,so after this the pointer "data" should be NULL.
The it calls "this->addObject()" without calls "initWithCapacity(n)".(like it does in the function "initWithObject").Now the pointer "data" is still NULL.
Then it will cause Memory Corruption in "ccArrayEnsureExtraCapacity()" int file "ccArray.cpp" in line 69.

My test code is :
qq20130802101010
and the debug info is:
qq20130802100955

这是我第一次用英文提交问题,也是我第一次提交问题,所以:
1.英文描述有可能极为蹩脚。
2.问题都可能不存在,虽然我尽可能的验证过,或许是我用得不对。所以如果发现问题是不存在的,请不要太责怪我。
3.如果需要进一步联系,邮件是:mywcyfl#163.com (#换成@).
4.Tthank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions