mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #6540: Fixed crash for bytearray.translate() with invalid parameters.
This commit is contained in:
parent
af2406f215
commit
ec812caf5d
3 changed files with 12 additions and 3 deletions
|
@ -1465,15 +1465,17 @@ bytearray_translate(PyByteArrayObject *self, PyObject *args)
|
|||
if (vtable.len != 256) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"translation table must be 256 characters long");
|
||||
goto done;
|
||||
PyBuffer_Release(&vtable);
|
||||
return NULL;
|
||||
}
|
||||
table = (const char*)vtable.buf;
|
||||
}
|
||||
|
||||
if (delobj != NULL) {
|
||||
if (_getbuffer(delobj, &vdel) < 0) {
|
||||
delobj = NULL; /* don't try to release vdel buffer on exit */
|
||||
goto done;
|
||||
if (tableobj != NULL)
|
||||
PyBuffer_Release(&vtable);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue