Raise MemoryError when failed to grow buffer (#263)

This commit is contained in:
INADA Naoki 2018-01-05 20:58:14 +09:00 committed by GitHub
parent 43137d6bd2
commit 1979722ba2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,7 +48,10 @@ static inline int msgpack_pack_write(msgpack_packer* pk, const char *data, size_
if (len + l > bs) {
bs = (len + l) * 2;
buf = (char*)PyMem_Realloc(buf, bs);
if (!buf) return -1;
if (!buf) {
PyErr_NoMemory();
return -1;
}
}
memcpy(buf + len, data, l);
len += l;