# HG changeset patch # User John Tsiombikas # Date 1386462452 -7200 # Node ID 8da36540e2e9c435ddc5afd372727f3bd4f6d748 # Parent f8bfc31775828851573f6d43f453f8d1a31de4d6 fixed memory leak in readxml and reversed error return diff -r f8bfc3177582 -r 8da36540e2e9 src/goat3d.cc --- a/src/goat3d.cc Sun Dec 08 02:14:46 2013 +0200 +++ b/src/goat3d.cc Sun Dec 08 02:27:32 2013 +0200 @@ -132,7 +132,7 @@ GOAT3DAPI int goat3d_load_io(struct goat3d *g, struct goat3d_io *io) { if(!g->scn->load(io)) { - if(g->scn->loadxml(io)) { + if(!g->scn->loadxml(io)) { return -1; } } diff -r f8bfc3177582 -r 8da36540e2e9 src/goat3d_readxml.cc --- a/src/goat3d_readxml.cc Sun Dec 08 02:14:46 2013 +0200 +++ b/src/goat3d_readxml.cc Sun Dec 08 02:27:32 2013 +0200 @@ -19,6 +19,7 @@ char *buf = new char[bytes]; if(io->read(buf, bytes, io->cls) < bytes) { logmsg(LOG_ERROR, "failed to read XML scene file\n"); + delete [] buf; return false; } @@ -27,12 +28,14 @@ if(err) { logmsg(LOG_ERROR, "failed to parse XML scene file: %s\n%s\n", xml.GetErrorStr1(), xml.GetErrorStr2()); + delete [] buf; return false; } XMLElement *root = xml.RootElement(); if(strcmp(root->Name(), "scene") != 0) { logmsg(LOG_ERROR, "invalid XML file, root node is not \n"); + delete [] buf; return false; } @@ -58,7 +61,8 @@ elem = elem->NextSiblingElement("mesh"); } - return false; + delete [] buf; + return true; }