mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
Fix Coverity warnings.
- Check the correct variable (str_obj, not str) for NULL - sep_len was already verified it wasn't 0
This commit is contained in:
parent
2f3136b8f0
commit
d1b6cd7bfb
2 changed files with 2 additions and 7 deletions
|
@ -58,7 +58,7 @@ stringlib_rpartition(
|
|||
)
|
||||
{
|
||||
PyObject* out;
|
||||
Py_ssize_t pos;
|
||||
Py_ssize_t pos, j;
|
||||
|
||||
if (sep_len == 0) {
|
||||
PyErr_SetString(PyExc_ValueError, "empty separator");
|
||||
|
@ -70,17 +70,12 @@ stringlib_rpartition(
|
|||
return NULL;
|
||||
|
||||
/* XXX - create reversefastsearch helper! */
|
||||
if (sep_len == 0)
|
||||
pos = str_len;
|
||||
else {
|
||||
Py_ssize_t j;
|
||||
pos = -1;
|
||||
for (j = str_len - sep_len; j >= 0; --j)
|
||||
if (STRINGLIB_CMP(str+j, sep, sep_len) == 0) {
|
||||
pos = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos < 0) {
|
||||
Py_INCREF(str_obj);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue