gh-150913: Fix sqlite3.Blob validation for empty slice assignment (GH… · python/cpython@fc9c4db

GitHub

Original file line numberDiff line numberDiff line change@@ -531,21 +531,25 @@ ass_subscript_slice(pysqlite_Blob *self, PyObject *item, PyObject *value)

531531return-1;

532532 }

533533534-if (len==0) {

535-return0;

536- }

537-538534Py_buffervbuf;

539535if (PyObject_GetBuffer(value, &vbuf, PyBUF_SIMPLE) <0) {

540536return-1;

541537 }

542538543-intrc=-1;

544539if (vbuf.len!=len) {

545540PyErr_SetString(PyExc_IndexError,

546541"Blob slice assignment is wrong size");

542+PyBuffer_Release(&vbuf);

543+return-1;

547544 }

548-elseif (step==1) {

545+546+if (len==0) {

547+PyBuffer_Release(&vbuf);

548+return0;

549+ }

550+551+intrc=-1;

552+if (step==1) {

549553rc=inner_write(self, vbuf.buf, len, start);

550554 }

551555else {