diff options
author | yoav@monfort.co.il <yoav@monfort.co.il> | 2016-02-07 20:24:28 +0200 |
---|---|---|
committer | yoav@monfort.co.il <yoav@monfort.co.il> | 2016-02-07 20:24:28 +0200 |
commit | fdbefc9d839c23442f773d340b2a65a03c77b427 (patch) | |
tree | abc52aa4d46d71598312cfd790d317ef1246c2b7 /deps/lua | |
parent | aa953b6ec3517b74b24e88bb76627faac431e239 (diff) | |
download | redis-fdbefc9d839c23442f773d340b2a65a03c77b427.tar.gz |
cmsgpack: pass correct osize values to lua allocator, update correct buf free space in cmsgpack
Diffstat (limited to 'deps/lua')
-rw-r--r-- | deps/lua/src/lua_cmsgpack.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/deps/lua/src/lua_cmsgpack.c b/deps/lua/src/lua_cmsgpack.c index 0b82d008d..7b8adb976 100644 --- a/deps/lua/src/lua_cmsgpack.c +++ b/deps/lua/src/lua_cmsgpack.c @@ -119,10 +119,10 @@ mp_buf *mp_buf_new(lua_State *L) { void mp_buf_append(mp_buf *buf, const unsigned char *s, size_t len) { if (buf->free < len) { - size_t newlen = buf->len+len; + size_t newsize = (buf->len+len)*2; - buf->b = (unsigned char*)mp_realloc(buf->L, buf->b, buf->len, newlen*2); - buf->free = newlen; + buf->b = (unsigned char*)mp_realloc(buf->L, buf->b, buf->len + buf->free, newsize); + buf->free = newsize - buf->len; } memcpy(buf->b+buf->len,s,len); buf->len += len; @@ -130,7 +130,7 @@ void mp_buf_append(mp_buf *buf, const unsigned char *s, size_t len) { } void mp_buf_free(mp_buf *buf) { - mp_realloc(buf->L, buf->b, buf->len, 0); /* realloc to 0 = free */ + mp_realloc(buf->L, buf->b, buf->len + buf->free, 0); /* realloc to 0 = free */ mp_realloc(buf->L, buf, sizeof(*buf), 0); } |