Avoid a potential NULL dereference when mutating args_str.

Coverit CID 221401
This commit is contained in:
Todd C. Miller
2021-04-23 19:05:45 -06:00
parent 65a55497ec
commit a85c6b41a6

View File

@@ -347,12 +347,12 @@ _py_debug_python_function(const char *class_name, const char *function_name, con
}
}
args_str = py_create_string_rep(py_args);
if (py_args_sorted != NULL)
Py_DECREF(py_args_sorted);
if (strncmp(args_str, "RC.", 3) == 0) {
if (args_str != NULL && strncmp(args_str, "RC.", 3) == 0) {
/* Strip leading RC. to match python 3.10 behavior. */
memmove(args_str, args_str + 3, strlen(args_str + 3) + 1);
}
if (py_args_sorted != NULL)
Py_DECREF(py_args_sorted);
}
if (py_kwargs != NULL) {
/* Sort by key for consistent output on Python < 3.6 */