Skip to content

Commit 749c7fa

Browse files
authored
Merge pull request #300 from jonathangreen/feature/version-check-code-review-updates
Update to libxml2 version incorporating code review feedback
2 parents 1525fe0 + b184cfe commit 749c7fa

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/lxml.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,18 @@ static int PyXmlSec_CheckLxmlLibraryVersion(void) {
6767
if (version == NULL) {
6868
goto FINALIZE;
6969
}
70-
if (!PyTuple_Check(version) || PyTuple_Size(version) != 3) {
70+
if (!PyTuple_Check(version) || PyTuple_Size(version) < 2) {
7171
goto FINALIZE;
7272
}
7373

7474
PyObject* major = PyTuple_GetItem(version, 0);
75+
if (major == NULL) {
76+
goto FINALIZE;
77+
}
7578
PyObject* minor = PyTuple_GetItem(version, 1);
79+
if (minor == NULL) {
80+
goto FINALIZE;
81+
}
7682

7783
if (!PyLong_Check(major) || !PyLong_Check(minor)) {
7884
goto FINALIZE;
@@ -85,9 +91,13 @@ static int PyXmlSec_CheckLxmlLibraryVersion(void) {
8591
result = 0;
8692

8793
FINALIZE:
94+
// Clear any errors that may have occurred
95+
PyErr_Clear();
96+
8897
// Cleanup our references, and return the result
8998
Py_XDECREF(lxml);
9099
Py_XDECREF(version);
100+
91101
return result;
92102
}
93103

0 commit comments

Comments
 (0)