Skip to content

Commit 1d0aeb6

Browse files
author
neal.norwitz
committed
Fix Coverity warnings.
- Check the correct variable (str_obj, not str) for NULL - sep_len was already verified it wasn't 0 git-svn-id: http://svn.python.org/projects/python/trunk@46431 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 2b1c79d commit 1d0aeb6

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

Objects/stringlib/partition.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ stringlib_rpartition(
5858
)
5959
{
6060
PyObject* out;
61-
Py_ssize_t pos;
61+
Py_ssize_t pos, j;
6262

6363
if (sep_len == 0) {
6464
PyErr_SetString(PyExc_ValueError, "empty separator");
@@ -70,17 +70,12 @@ stringlib_rpartition(
7070
return NULL;
7171

7272
/* XXX - create reversefastsearch helper! */
73-
if (sep_len == 0)
74-
pos = str_len;
75-
else {
76-
Py_ssize_t j;
7773
pos = -1;
7874
for (j = str_len - sep_len; j >= 0; --j)
7975
if (STRINGLIB_CMP(str+j, sep, sep_len) == 0) {
8076
pos = j;
8177
break;
8278
}
83-
}
8479

8580
if (pos < 0) {
8681
Py_INCREF(str_obj);

Objects/unicodeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3955,7 +3955,7 @@ Py_ssize_t PyUnicode_Find(PyObject *str,
39553955
PyUnicodeObject* sub_obj;
39563956

39573957
str_obj = (PyUnicodeObject*) PyUnicode_FromObject(str);
3958-
if (!str)
3958+
if (!str_obj)
39593959
return -2;
39603960
sub_obj = (PyUnicodeObject*) PyUnicode_FromObject(substr);
39613961
if (!sub_obj) {

0 commit comments

Comments
 (0)