Skip to content

Commit 65f9beb

Browse files
Navjot SinghNavjot Singh
authored andcommitted
fixed segmentation fault
1 parent 5c6fc58 commit 65f9beb

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

bson/_cbsonmodule.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,6 @@ int write_dict(PyObject* self, buffer_t buffer,
17491749
PyObject *InvalidDocument = _error("InvalidDocument");
17501750

17511751
if (PyErr_GivenExceptionMatches(etype, InvalidDocument)) {
1752-
17531752
if (InvalidDocument) {
17541753
Py_DECREF(etype);
17551754
etype = InvalidDocument;
@@ -1766,21 +1765,19 @@ int write_dict(PyObject* self, buffer_t buffer,
17661765

17671766
if (new_msg) {
17681767
evalue = new_msg;
1769-
Py_DECREF(new_msg);
17701768
}
1771-
else{
1769+
else {
17721770
evalue = msg;
17731771
}
1774-
1775-
Py_DECREF(msg);
1776-
17771772
}
17781773
}
17791774
PyErr_NormalizeException(&etype, &evalue, &etrace);
17801775
}
17811776
}
1777+
else {
1778+
Py_DECREF(InvalidDocument);
1779+
}
17821780
PyErr_Restore(etype, evalue, etrace);
1783-
Py_DECREF(InvalidDocument);
17841781
}
17851782
return 0;
17861783
}

0 commit comments

Comments
 (0)