Merge pull request #31 from redboltz/fix_buffer_leak

Fixed buffer leak bug.

In the case of the function next() returns true:
Whichever the argument result is holding the zone or not, the ownership of the zone always should be delegated from 'unpacker' to 'unpacked'.

In the case of the function next() returns false:
Whichever the argument result is holding the zone or not, the members of 'unpacked' should be reset.
This commit is contained in:
Takatoshi Kondo 2013-10-14 23:59:04 -07:00
commit dc1698eaf4

View File

@ -226,12 +226,12 @@ inline bool unpacker::next(unpacked* result)
}
if(ret == 0) {
if (result->zone().get() != NULL) result->zone().reset();
result->zone().reset();
result->get() = object();
return false;
} else {
if (result->zone().get() != NULL) result->zone().reset( release_zone() );
result->zone().reset( release_zone() );
result->get() = data();
reset();
return true;