Issue #18408: Fix CJK decoders, raise MemoryError on memory allocation failure

This commit is contained in:
Victor Stinner 2013-07-15 17:47:39 +02:00
parent 54b2d2ec69
commit 33283ba300
1 changed files with 3 additions and 1 deletions

View File

@ -1053,8 +1053,10 @@ mbidecoder_decode(MultibyteIncrementalDecoderObject *self,
} }
wsize = size + self->pendingsize; wsize = size + self->pendingsize;
wdata = PyMem_Malloc(wsize); wdata = PyMem_Malloc(wsize);
if (wdata == NULL) if (wdata == NULL) {
PyErr_NoMemory();
goto errorexit; goto errorexit;
}
memcpy(wdata, self->pending, self->pendingsize); memcpy(wdata, self->pending, self->pendingsize);
memcpy(wdata + self->pendingsize, data, size); memcpy(wdata + self->pendingsize, data, size);
self->pendingsize = 0; self->pendingsize = 0;