[Zope-CVS] CVS: Products/ZCTextIndex - okascore.c:1.2

Tim Peters tim.one@comcast.net
Tue, 21 May 2002 12:02:44 -0400


Update of /cvs-repository/Products/ZCTextIndex
In directory cvs.zope.org:/tmp/cvs-serv29551

Modified Files:
	okascore.c 
Log Message:
PyInt_FromLong() can fail, so check the return for NULL.


=== Products/ZCTextIndex/okascore.c 1.1 => 1.2 ===
 		score = tf * idf;
 		scaled_int = PyInt_FromLong((long)(score * 1024.0 + 0.5));
-		status = PyObject_SetItem(result, d, scaled_int);
+		if (scaled_int == NULL)
+			status = -1;
+		else
+			status = PyObject_SetItem(result, d, scaled_int);
 		Py_DECREF(d_and_f);
 		Py_DECREF(doclen);
-		Py_DECREF(scaled_int);
+		Py_XDECREF(scaled_int);
 		if (status < 0)
 			return NULL;
 	}