diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-03-02 17:16:38 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-03-02 17:16:38 (GMT) |
commit | b2677c739729ace08c4185d1e459210373477497 (patch) | |
tree | a0a8166ddcc05cfa59ecfe3632e318553ac080f6 /Python/marshal.c | |
parent | 92818d5383087d238f24b0a93d31a41bf6a75735 (diff) | |
parent | 679e9d36f78de3ac18abaaddbcf4f73fcef55b7e (diff) | |
download | cpython-b2677c739729ace08c4185d1e459210373477497.zip cpython-b2677c739729ace08c4185d1e459210373477497.tar.gz cpython-b2677c739729ace08c4185d1e459210373477497.tar.bz2 |
Issue #14172: Fix reference leak when marshalling a buffer-like object (other than a bytes object).
Diffstat (limited to 'Python/marshal.c')
-rw-r--r-- | Python/marshal.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/marshal.c b/Python/marshal.c index 98bbbaf..17353b2 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -409,11 +409,12 @@ w_object(PyObject *v, WFILE *p) else if (PyObject_CheckBuffer(v)) { /* Write unknown buffer-style objects as a string */ char *s; - PyBufferProcs *pb = v->ob_type->tp_as_buffer; Py_buffer view; - if ((*pb->bf_getbuffer)(v, &view, PyBUF_SIMPLE) != 0) { + if (PyObject_GetBuffer(v, &view, PyBUF_SIMPLE) != 0) { w_byte(TYPE_UNKNOWN, p); + p->depth--; p->error = WFERR_UNMARSHALLABLE; + return; } w_byte(TYPE_STRING, p); n = view.len; @@ -425,8 +426,7 @@ w_object(PyObject *v, WFILE *p) } w_long((long)n, p); w_string(s, (int)n, p); - if (pb->bf_releasebuffer != NULL) - (*pb->bf_releasebuffer)(v, &view); + PyBuffer_Release(&view); } else { w_byte(TYPE_UNKNOWN, p); |