Kaydet (Commit) d1b6cd7b authored tarafından Neal Norwitz's avatar Neal Norwitz

Fix Coverity warnings.

 - Check the correct variable (str_obj, not str) for NULL
 - sep_len was already verified it wasn't 0
üst 2f3136b8
...@@ -58,7 +58,7 @@ stringlib_rpartition( ...@@ -58,7 +58,7 @@ stringlib_rpartition(
) )
{ {
PyObject* out; PyObject* out;
Py_ssize_t pos; Py_ssize_t pos, j;
if (sep_len == 0) { if (sep_len == 0) {
PyErr_SetString(PyExc_ValueError, "empty separator"); PyErr_SetString(PyExc_ValueError, "empty separator");
...@@ -70,17 +70,12 @@ stringlib_rpartition( ...@@ -70,17 +70,12 @@ stringlib_rpartition(
return NULL; return NULL;
/* XXX - create reversefastsearch helper! */ /* XXX - create reversefastsearch helper! */
if (sep_len == 0)
pos = str_len;
else {
Py_ssize_t j;
pos = -1; pos = -1;
for (j = str_len - sep_len; j >= 0; --j) for (j = str_len - sep_len; j >= 0; --j)
if (STRINGLIB_CMP(str+j, sep, sep_len) == 0) { if (STRINGLIB_CMP(str+j, sep, sep_len) == 0) {
pos = j; pos = j;
break; break;
} }
}
if (pos < 0) { if (pos < 0) {
Py_INCREF(str_obj); Py_INCREF(str_obj);
......
...@@ -3955,7 +3955,7 @@ Py_ssize_t PyUnicode_Find(PyObject *str, ...@@ -3955,7 +3955,7 @@ Py_ssize_t PyUnicode_Find(PyObject *str,
PyUnicodeObject* sub_obj; PyUnicodeObject* sub_obj;
str_obj = (PyUnicodeObject*) PyUnicode_FromObject(str); str_obj = (PyUnicodeObject*) PyUnicode_FromObject(str);
if (!str) if (!str_obj)
return -2; return -2;
sub_obj = (PyUnicodeObject*) PyUnicode_FromObject(substr); sub_obj = (PyUnicodeObject*) PyUnicode_FromObject(substr);
if (!sub_obj) { if (!sub_obj) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment