summaryrefslogtreecommitdiff
path: root/msgpack/_msgpack.pyx
diff options
context:
space:
mode:
authorINADA Naoki <inada-n@klab.com>2012-12-10 01:42:38 +0900
committerINADA Naoki <inada-n@klab.com>2012-12-10 01:42:38 +0900
commited40c671dac175e437fe67689053b5fe8a269ad3 (patch)
treed1df1a59c3fda098b2395faed2b193118166c8f4 /msgpack/_msgpack.pyx
parent4480227e066e66fd771dc1702adf4929dede453d (diff)
downloadmsgpack-python-ed40c671dac175e437fe67689053b5fe8a269ad3.tar.gz
`pack` raise MemoryError when realloc is failed.
Diffstat (limited to 'msgpack/_msgpack.pyx')
-rw-r--r--msgpack/_msgpack.pyx4
1 files changed, 3 insertions, 1 deletions
diff --git a/msgpack/_msgpack.pyx b/msgpack/_msgpack.pyx
index 2c81cb4..b2b5222 100644
--- a/msgpack/_msgpack.pyx
+++ b/msgpack/_msgpack.pyx
@@ -179,7 +179,9 @@ cdef class Packer(object):
cpdef pack(self, object obj):
cdef int ret
ret = self._pack(obj, DEFAULT_RECURSE_LIMIT)
- if ret:
+ if ret == -1:
+ raise MemoryError
+ elif ret: # should not happen.
raise TypeError
buf = PyBytes_FromStringAndSize(self.pk.buf, self.pk.length)
self.pk.length = 0