Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a9c436

Browse files
committed
PyObject_IsTrue() can return an error condition.
Adding code to handle it properly.
1 parent 863983e commit 9a9c436

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Modules/_randommodule.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ random_seed(RandomObject *self, PyObject *args)
213213
unsigned long *key = NULL;
214214
unsigned long keymax; /* # of allocated slots in key */
215215
unsigned long keyused; /* # of used slots in key */
216+
int err;
216217

217218
PyObject *arg = NULL;
218219

@@ -261,11 +262,13 @@ random_seed(RandomObject *self, PyObject *args)
261262
thirtytwo = PyInt_FromLong(32L);
262263
if (thirtytwo == NULL)
263264
goto Done;
264-
while (PyObject_IsTrue(n)) {
265+
while ((err=PyObject_IsTrue(n))) {
265266
PyObject *newn;
266267
PyObject *pychunk;
267268
unsigned long chunk;
268269

270+
if (err == -1)
271+
goto Done;
269272
pychunk = PyNumber_And(n, masklower);
270273
if (pychunk == NULL)
271274
goto Done;

0 commit comments

Comments
 (0)