lundi 1 juin 2015

Why is this pointer freed even though it was not allocated?

I have a class:

class World {

    std::vector<Segment> segments;

}

A Segment is added to segments like this:

void World::createSegments(){
    ....
    Segment segment = Segment();
    this->segments.push_back(segment); 

    //Xcode reports error here (after running above line)
}

Xcode reports this error:

malloc: * error for object 0x79e464f8: pointer being freed was not allocated * set a breakpoint in malloc_error_break to debug

There is no runtime or compile time error - this message just appears in the debugger while my app is running.

What am I doing wrong ?

Aucun commentaire:

Enregistrer un commentaire