[Python-checkins] r46431 - in python/trunk/Objects: stringlib/partition.h unicodeobject.c
neal.norwitz
python-checkins at python.org
Sat May 27 07:21:30 CEST 2006
Author: neal.norwitz
Date: Sat May 27 07:21:30 2006
New Revision: 46431
Modified:
python/trunk/Objects/stringlib/partition.h
python/trunk/Objects/unicodeobject.c
Log:
Fix Coverity warnings.
- Check the correct variable (str_obj, not str) for NULL
- sep_len was already verified it wasn't 0
Modified: python/trunk/Objects/stringlib/partition.h
==============================================================================
--- python/trunk/Objects/stringlib/partition.h (original)
+++ python/trunk/Objects/stringlib/partition.h Sat May 27 07:21:30 2006
@@ -58,7 +58,7 @@
)
{
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 @@
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);
Modified: python/trunk/Objects/unicodeobject.c
==============================================================================
--- python/trunk/Objects/unicodeobject.c (original)
+++ python/trunk/Objects/unicodeobject.c Sat May 27 07:21:30 2006
@@ -3955,7 +3955,7 @@
PyUnicodeObject* sub_obj;
str_obj = (PyUnicodeObject*) PyUnicode_FromObject(str);
- if (!str)
+ if (!str_obj)
return -2;
sub_obj = (PyUnicodeObject*) PyUnicode_FromObject(substr);
if (!sub_obj) {
More information about the Python-checkins
mailing list