Fixed memory size caluclation problem.

See https://github.com/msgpack/msgpack-c/issues/149
This commit is contained in:
Takatoshi Kondo
2014-11-01 19:41:47 +09:00
parent 96c688708c
commit d6cc5494a9
10 changed files with 70 additions and 13 deletions

View File

@@ -179,7 +179,12 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to)
const size_t reqsize = nused + tosize;
size_t nnext = (size_t)(to->end - to->array) * 2;
while(nnext < reqsize) {
nnext *= 2;
size_t tmp_nnext = nnext * 2;
if (tmp_nnext <= nnext) {
nnext = reqsize;
break;
}
nnext = tmp_nnext;
}
struct iovec* nvec = (struct iovec*)realloc(