When the original PR was applied, the resource leak had been fixed, but a dual free problem had been happened.

When msgpack_unpacker_next returns MSGPACK_UNPACK_CONTINUE, msgpack_unpacked::zone is not replaced. Then mespack_zone_free is called twice with the same object. msgpack_unpacked_destroy frees msgpack::zone when it is not NULL and set it to NULL.

Also, fixed memory leak (msgpack_sbuffer) on the test code.
This commit is contained in:
Takatoshi Kondo
2014-09-07 13:56:07 +09:00
parent 7ebdb63131
commit 11f1d5fbbd
2 changed files with 2 additions and 4 deletions

View File

@@ -492,9 +492,7 @@ void msgpack_unpacker_reset(msgpack_unpacker* mpac)
msgpack_unpack_return msgpack_unpacker_next(msgpack_unpacker* mpac, msgpack_unpacked* result) msgpack_unpack_return msgpack_unpacker_next(msgpack_unpacker* mpac, msgpack_unpacked* result)
{ {
if(result->zone != NULL) { msgpack_unpacked_destroy(result);
msgpack_zone_free(result->zone);
}
int ret = msgpack_unpacker_execute(mpac); int ret = msgpack_unpacker_execute(mpac);

View File

@@ -110,5 +110,5 @@ TEST(streaming, basic)
msgpack_unpacker_destroy(&pac); msgpack_unpacker_destroy(&pac);
msgpack_unpacked_destroy(&result); msgpack_unpacked_destroy(&result);
msgpack_sbuffer_free(buffer);
} }