Skip to content

Commit a359dda

Browse files
Fix a NULL dereference.
1 parent 638baca commit a359dda

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Lib/test/test_cmd_line.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def test_run_module_bug1764407(self):
198198
p.stdin.write(b'Timer\n')
199199
p.stdin.write(b'exit()\n')
200200
data = kill_python(p)
201-
self.assertTrue(data.find(b'1 loop') != -1)
201+
self.assertIn(b'1 loop', data)
202202
self.assertTrue(data.find(b'__main__.Timer') != -1)
203203

204204
def test_relativedir_bug46421(self):

Python/_warnings.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,17 @@ check_matched(PyInterpreterState *interp, PyObject *obj, PyObject *arg, PyObject
180180
if (obj == Py_None)
181181
return 1;
182182

183-
/* An internal plain text default filter must match exactly */
184-
if (PyUnicode_CheckExact(obj)) {
185-
int cmp_result = PyUnicode_Compare(obj, arg);
186-
if (cmp_result == -1 && PyErr_Occurred()) {
187-
return -1;
183+
if (arg != NULL) {
184+
/* An internal plain text default filter must match exactly */
185+
if (PyUnicode_CheckExact(obj)) {
186+
int cmp_result = PyUnicode_Compare(obj, arg);
187+
if (cmp_result == -1 && PyErr_Occurred()) {
188+
return -1;
189+
}
190+
return !cmp_result;
188191
}
189-
return !cmp_result;
190-
}
191192

192-
/* Otherwise assume a regex filter and call its match() method */
193-
if (arg != NULL) {
193+
/* Otherwise assume a regex filter and call its match() method */
194194
result = PyObject_CallMethodOneArg(obj, &_Py_ID(match), arg);
195195
}
196196
else {

0 commit comments

Comments
 (0)