File: src/_fastmath.c
Function: getRandomInteger
Error: dereferencing NULL (rand_bytes->ob_type) at src/_fastmath.c:1158
1122 static int
1123 getRandomInteger (mpz_t n, unsigned long int bits, PyObject *randfunc_)
1124 {
1125 	PyObject *arglist, *randfunc=NULL, *rng=NULL, *rand_bytes=NULL;
1126 	int return_val = 1;
1127 	unsigned long int bytes = bits / 8;
1128 	unsigned long int odd_bits = bits % 8;
1129 	/* generate 1 to 8 bits too many.
1130 	   we will remove them later by right-shifting */
1131 	bytes++;
1132 	/* we need to handle the cases where randfunc is NULL or None */
1133 	if ((randfunc_ == NULL) || (randfunc_ == Py_None))
taking False path
taking False path
1134 	{
1135 		rng = getRNG();
1136 		if (!rng)
1137 		{
1138 			return_val = 0;
1139 			goto cleanup;
1140 		}
1141 		randfunc = PyObject_GetAttrString (rng, "read");
1142 	}
1143 	else
1144 	{
1145 		randfunc = randfunc_;
1146 	}
1147 
1148 	if (!PyCallable_Check (randfunc))
when PyCallable_Check() returns 1 (true)
taking False path
1149 	{
1150 		PyErr_SetString (PyExc_TypeError, "randfunc must be callable");
1151 		return_val = 0;
1152 		goto cleanup;
1153 	}
1154 
1155 	arglist = Py_BuildValue ("(l)", (long int)bytes);
when Py_BuildValue() succeeds
1156 	rand_bytes = PyObject_CallObject (randfunc, arglist);
when PyObject_CallObject() fails
1157 	Py_DECREF (arglist);
when taking True path
1158 	if (!PyBytes_Check (rand_bytes))
dereferencing NULL (rand_bytes->ob_type) at src/_fastmath.c:1158
found 1 similar trace(s) to this
1159 	{
1160 		PyErr_SetString (PyExc_TypeError,
1161 						 "randfunc must return a string of random bytes");
1162 		return_val = 0;
1163 		goto cleanup;
1164 	}
1165 
1166 	bytes_to_mpz (n, (unsigned char *)PyBytes_AsString(rand_bytes), bytes);
1167 	/* remove superflous bits by right-shifting */
1168 	mpz_fdiv_q_2exp (n, n, 8 - odd_bits);
1169 
1170 cleanup:
1171 	Py_XDECREF (rand_bytes);
1172 	if (rng)
1173 	{
1174 		Py_XDECREF (randfunc);
1175 		Py_DECREF (rng);
1176 	}
1177 	return return_val;
1178 }

File: src/_fastmath.c
Function: getRandomInteger
Error: dereferencing NULL (arglist->ob_refcnt) at src/_fastmath.c:1157
1122 static int
1123 getRandomInteger (mpz_t n, unsigned long int bits, PyObject *randfunc_)
1124 {
1125 	PyObject *arglist, *randfunc=NULL, *rng=NULL, *rand_bytes=NULL;
1126 	int return_val = 1;
1127 	unsigned long int bytes = bits / 8;
1128 	unsigned long int odd_bits = bits % 8;
1129 	/* generate 1 to 8 bits too many.
1130 	   we will remove them later by right-shifting */
1131 	bytes++;
1132 	/* we need to handle the cases where randfunc is NULL or None */
1133 	if ((randfunc_ == NULL) || (randfunc_ == Py_None))
taking False path
taking False path
1134 	{
1135 		rng = getRNG();
1136 		if (!rng)
1137 		{
1138 			return_val = 0;
1139 			goto cleanup;
1140 		}
1141 		randfunc = PyObject_GetAttrString (rng, "read");
1142 	}
1143 	else
1144 	{
1145 		randfunc = randfunc_;
1146 	}
1147 
1148 	if (!PyCallable_Check (randfunc))
when PyCallable_Check() returns 1 (true)
taking False path
1149 	{
1150 		PyErr_SetString (PyExc_TypeError, "randfunc must be callable");
1151 		return_val = 0;
1152 		goto cleanup;
1153 	}
1154 
1155 	arglist = Py_BuildValue ("(l)", (long int)bytes);
when Py_BuildValue() fails
1156 	rand_bytes = PyObject_CallObject (randfunc, arglist);
when PyObject_CallObject() succeeds
1157 	Py_DECREF (arglist);
dereferencing NULL (arglist->ob_refcnt) at src/_fastmath.c:1157
found 1 similar trace(s) to this
1158 	if (!PyBytes_Check (rand_bytes))
1159 	{
1160 		PyErr_SetString (PyExc_TypeError,
1161 						 "randfunc must return a string of random bytes");
1162 		return_val = 0;
1163 		goto cleanup;
1164 	}
1165 
1166 	bytes_to_mpz (n, (unsigned char *)PyBytes_AsString(rand_bytes), bytes);
1167 	/* remove superflous bits by right-shifting */
1168 	mpz_fdiv_q_2exp (n, n, 8 - odd_bits);
1169 
1170 cleanup:
1171 	Py_XDECREF (rand_bytes);
1172 	if (rng)
1173 	{
1174 		Py_XDECREF (randfunc);
1175 		Py_DECREF (rng);
1176 	}
1177 	return return_val;
1178 }