Skip to content

Commit 3e83424

Browse files
committed
Correct failure path
The previous code left the mutex acquired on failure. It is now correctly released
1 parent 754de2d commit 3e83424

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/session.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,19 +1939,19 @@ APSWChangeset_apply(PyObject *self_, PyObject *const *fast_args, Py_ssize_t fast
19391939
else
19401940
{
19411941
Py_buffer changeset_buffer;
1942-
if (0 != PyObject_GetBufferContiguousBounded(changeset, &changeset_buffer, PyBUF_SIMPLE, INT32_MAX))
1942+
if (0 == PyObject_GetBufferContiguousBounded(changeset, &changeset_buffer, PyBUF_SIMPLE, INT32_MAX))
19431943
{
1944-
assert(PyErr_Occurred());
1945-
return NULL;
1944+
res = filter ? sqlite3changeset_apply_v2(db->db, changeset_buffer.len, changeset_buffer.buf,
1945+
filter ? applyFilter : NULL, conflict ? applyConflict : conflictReject,
1946+
&aic, rebase ? &pRebase : NULL, rebase ? &nRebase : NULL, flags)
1947+
: sqlite3changeset_apply_v3(db->db, changeset_buffer.len, changeset_buffer.buf,
1948+
filter_change ? applyFilterChange : NULL,
1949+
conflict ? applyConflict : conflictReject, &aic,
1950+
rebase ? &pRebase : NULL, rebase ? &nRebase : NULL, flags);
1951+
PyBuffer_Release(&changeset_buffer);
19461952
}
1947-
res = filter ? sqlite3changeset_apply_v2(db->db, changeset_buffer.len, changeset_buffer.buf,
1948-
filter ? applyFilter : NULL, conflict ? applyConflict : conflictReject,
1949-
&aic, rebase ? &pRebase : NULL, rebase ? &nRebase : NULL, flags)
1950-
: sqlite3changeset_apply_v3(db->db, changeset_buffer.len, changeset_buffer.buf,
1951-
filter_change ? applyFilterChange : NULL,
1952-
conflict ? applyConflict : conflictReject, &aic, rebase ? &pRebase : NULL,
1953-
rebase ? &nRebase : NULL, flags);
1954-
PyBuffer_Release(&changeset_buffer);
1953+
else
1954+
assert(PyErr_Occurred());
19551955
}
19561956

19571957
sqlite3_mutex_leave(db->dbmutex);

0 commit comments

Comments
 (0)