File: _mysql.c
Function: _mysql_server_init
Error: memory leak: ob_refcnt of new ref from (unknown) _mysql_Exception is 1 too high
259 static PyObject *_mysql_server_init(
260 	PyObject *self,
261 	PyObject *args,
262 	PyObject *kwargs) {
263 	static char *kwlist[] = {"args", "groups", NULL};
264 	char **cmd_args_c=NULL, **groups_c=NULL, *s;
265 	int cmd_argc=0, i, groupc;
266 	PyObject *cmd_args=NULL, *groups=NULL, *ret=NULL, *item;
267 
268 	if (_mysql_server_init_done) {
269 		PyErr_SetString(_mysql_ProgrammingError,
when considering value == (int)0 from _mysql.c:121
taking False path
270 				"already initialized");
271 		return NULL;
272 	}
273 	  
274 	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO", kwlist,
275 					 &cmd_args, &groups))
when PyArg_ParseTupleAndKeywords() succeeds
taking False path
276 		return NULL;
277 
278 #if MYSQL_VERSION_ID >= 40000
279 	if (cmd_args) {
280 		if (!PySequence_Check(cmd_args)) {
taking True path
281 			PyErr_SetString(PyExc_TypeError,
when considering range: -0x80000000 <= value <= -1
taking False path
282 					"args must be a sequence");
283 			goto finish;
284 		}
285 		cmd_argc = PySequence_Size(cmd_args);
286 		if (cmd_argc == -1) {
when PySequence_Size() succeeds
287 			PyErr_SetString(PyExc_TypeError,
when considering range: -0x80000000 <= value <= -2
taking False path
288 					"args could not be sized");
289 			goto finish;
290 		}
291 		cmd_args_c = (char **) PyMem_Malloc(cmd_argc*sizeof(char *));
292 		for (i=0; i< cmd_argc; i++) {
when PyMem_Malloc() succeeds
293 			item = PySequence_GetItem(cmd_args, i);
taking False path
294 			s = get_string(item);
295 
296 			Py_DECREF(item);
297 			if (!s) { goto finish; }
298 			cmd_args_c[i] = s;
299 		}
300 	}
301 	if (groups) {
302 		if (!PySequence_Check(groups)) {
taking True path
303 			PyErr_SetString(PyExc_TypeError,
when considering range: 1 <= value <= 0x7fffffff
taking False path
304 					"groups must be a sequence");
305 			goto finish;
306 		}
307 		groupc = PySequence_Size(groups);
308 		if (groupc == -1) {
when PySequence_Size() succeeds
309 			PyErr_SetString(PyExc_TypeError,
when considering range: 0 <= value <= 0x7fffffff
taking False path
310 					"groups could not be sized");
311 			goto finish;
312 		}
313 		groups_c = (char **) PyMem_Malloc((1+groupc)*sizeof(char *));
314 		for (i=0; i< groupc; i++) {
when PyMem_Malloc() succeeds
315 			item = PySequence_GetItem(groups, i);
when considering range: 1 <= groupc <= 0x7fffffff
taking True path
when considering groupc == (int)1 from _mysql.c:308
taking False path
316 			s = get_string(item);
when PySequence_GetItem() succeeds
317 			Py_DECREF(item);
318 			if (!s) { goto finish; }
when taking False path
calling tp_dealloc on new ref from PySequence_GetItem allocated at _mysql.c:316
319 			groups_c[i] = s;
when treating unknown char * from _mysql.c:317 as non-NULL
taking False path
320 		}
321 		groups_c[groupc] = (char *)NULL;
322 	}
323 	/* even though this may block, don't give up the interpreter lock
324 	   so that the server can't be initialized multiple times. */
325 	if (mysql_server_init(cmd_argc, cmd_args_c, groups_c)) {
326 		_mysql_Exception(NULL);
when considering range: -0x80000000 <= value <= -1
taking True path
327 		goto finish;
when _mysql_Exception() succeeds
new ref from (unknown) _mysql_Exception was allocated at: 		_mysql_Exception(NULL);
ob_refcnt is now refs: 1 owned
328 	}
329 #endif
330 	ret = Py_None;
331 	Py_INCREF(Py_None);
332 	_mysql_server_init_done = 1;
333   finish:
334 	PyMem_Free(groups_c);
335 	PyMem_Free(cmd_args_c);
calling PyMem_Free on PyMem_Malloc allocated at _mysql.c:314
336 	return ret;
calling PyMem_Free on PyMem_Malloc allocated at _mysql.c:292
337 }
338 

File: _mysql.c
Function: _mysql_server_init
Error: returning (PyObject*)NULL without setting an exception
259 static PyObject *_mysql_server_init(
260 	PyObject *self,
261 	PyObject *args,
262 	PyObject *kwargs) {
263 	static char *kwlist[] = {"args", "groups", NULL};
264 	char **cmd_args_c=NULL, **groups_c=NULL, *s;
265 	int cmd_argc=0, i, groupc;
266 	PyObject *cmd_args=NULL, *groups=NULL, *ret=NULL, *item;
267 
268 	if (_mysql_server_init_done) {
269 		PyErr_SetString(_mysql_ProgrammingError,
when considering value == (int)0 from _mysql.c:121
taking False path
270 				"already initialized");
271 		return NULL;
272 	}
273 	  
274 	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO", kwlist,
275 					 &cmd_args, &groups))
when PyArg_ParseTupleAndKeywords() succeeds
taking False path
276 		return NULL;
277 
278 #if MYSQL_VERSION_ID >= 40000
279 	if (cmd_args) {
280 		if (!PySequence_Check(cmd_args)) {
taking True path
281 			PyErr_SetString(PyExc_TypeError,
when considering range: -0x80000000 <= value <= -1
taking False path
282 					"args must be a sequence");
283 			goto finish;
284 		}
285 		cmd_argc = PySequence_Size(cmd_args);
286 		if (cmd_argc == -1) {
when PySequence_Size() succeeds
287 			PyErr_SetString(PyExc_TypeError,
when considering range: -0x80000000 <= value <= -2
taking False path
288 					"args could not be sized");
289 			goto finish;
290 		}
291 		cmd_args_c = (char **) PyMem_Malloc(cmd_argc*sizeof(char *));
292 		for (i=0; i< cmd_argc; i++) {
when PyMem_Malloc() succeeds
293 			item = PySequence_GetItem(cmd_args, i);
taking False path
294 			s = get_string(item);
295 
296 			Py_DECREF(item);
297 			if (!s) { goto finish; }
298 			cmd_args_c[i] = s;
299 		}
300 	}
301 	if (groups) {
302 		if (!PySequence_Check(groups)) {
taking True path
303 			PyErr_SetString(PyExc_TypeError,
when considering range: 1 <= value <= 0x7fffffff
taking False path
304 					"groups must be a sequence");
305 			goto finish;
306 		}
307 		groupc = PySequence_Size(groups);
308 		if (groupc == -1) {
when PySequence_Size() succeeds
309 			PyErr_SetString(PyExc_TypeError,
when considering range: 0 <= value <= 0x7fffffff
taking False path
310 					"groups could not be sized");
311 			goto finish;
312 		}
313 		groups_c = (char **) PyMem_Malloc((1+groupc)*sizeof(char *));
314 		for (i=0; i< groupc; i++) {
when PyMem_Malloc() succeeds
315 			item = PySequence_GetItem(groups, i);
when considering range: 1 <= groupc <= 0x7fffffff
taking True path
when considering groupc == (int)1 from _mysql.c:308
taking False path
316 			s = get_string(item);
when PySequence_GetItem() succeeds
317 			Py_DECREF(item);
318 			if (!s) { goto finish; }
when taking False path
calling tp_dealloc on new ref from PySequence_GetItem allocated at _mysql.c:316
319 			groups_c[i] = s;
when treating unknown char * from _mysql.c:317 as non-NULL
taking False path
320 		}
321 		groups_c[groupc] = (char *)NULL;
322 	}
323 	/* even though this may block, don't give up the interpreter lock
324 	   so that the server can't be initialized multiple times. */
325 	if (mysql_server_init(cmd_argc, cmd_args_c, groups_c)) {
326 		_mysql_Exception(NULL);
when considering range: -0x80000000 <= value <= -1
taking True path
327 		goto finish;
when _mysql_Exception() succeeds
328 	}
329 #endif
330 	ret = Py_None;
331 	Py_INCREF(Py_None);
332 	_mysql_server_init_done = 1;
333   finish:
334 	PyMem_Free(groups_c);
335 	PyMem_Free(cmd_args_c);
calling PyMem_Free on PyMem_Malloc allocated at _mysql.c:314
336 	return ret;
calling PyMem_Free on PyMem_Malloc allocated at _mysql.c:292
337 }
338 

File: _mysql.c
Function: _mysql_server_init
Error: dereferencing NULL (item->ob_refcnt) at _mysql.c:318
259 static PyObject *_mysql_server_init(
260 	PyObject *self,
261 	PyObject *args,
262 	PyObject *kwargs) {
263 	static char *kwlist[] = {"args", "groups", NULL};
264 	char **cmd_args_c=NULL, **groups_c=NULL, *s;
265 	int cmd_argc=0, i, groupc;
266 	PyObject *cmd_args=NULL, *groups=NULL, *ret=NULL, *item;
267 
268 	if (_mysql_server_init_done) {
269 		PyErr_SetString(_mysql_ProgrammingError,
when considering value == (int)0 from _mysql.c:121
taking False path
270 				"already initialized");
271 		return NULL;
272 	}
273 	  
274 	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO", kwlist,
275 					 &cmd_args, &groups))
when PyArg_ParseTupleAndKeywords() succeeds
taking False path
276 		return NULL;
277 
278 #if MYSQL_VERSION_ID >= 40000
279 	if (cmd_args) {
280 		if (!PySequence_Check(cmd_args)) {
taking True path
281 			PyErr_SetString(PyExc_TypeError,
when considering range: -0x80000000 <= value <= -1
taking False path
282 					"args must be a sequence");
283 			goto finish;
284 		}
285 		cmd_argc = PySequence_Size(cmd_args);
286 		if (cmd_argc == -1) {
when PySequence_Size() succeeds
287 			PyErr_SetString(PyExc_TypeError,
when considering range: -0x80000000 <= value <= -2
taking False path
288 					"args could not be sized");
289 			goto finish;
290 		}
291 		cmd_args_c = (char **) PyMem_Malloc(cmd_argc*sizeof(char *));
292 		for (i=0; i< cmd_argc; i++) {
when PyMem_Malloc() succeeds
293 			item = PySequence_GetItem(cmd_args, i);
taking False path
294 			s = get_string(item);
295 
296 			Py_DECREF(item);
297 			if (!s) { goto finish; }
298 			cmd_args_c[i] = s;
299 		}
300 	}
301 	if (groups) {
302 		if (!PySequence_Check(groups)) {
taking True path
303 			PyErr_SetString(PyExc_TypeError,
when considering range: -0x80000000 <= value <= -1
taking False path
304 					"groups must be a sequence");
305 			goto finish;
306 		}
307 		groupc = PySequence_Size(groups);
308 		if (groupc == -1) {
when PySequence_Size() succeeds
309 			PyErr_SetString(PyExc_TypeError,
when considering range: 0 <= value <= 0x7fffffff
taking False path
310 					"groups could not be sized");
311 			goto finish;
312 		}
313 		groups_c = (char **) PyMem_Malloc((1+groupc)*sizeof(char *));
314 		for (i=0; i< groupc; i++) {
when PyMem_Malloc() succeeds
315 			item = PySequence_GetItem(groups, i);
when considering range: 1 <= groupc <= 0x7fffffff
taking True path
316 			s = get_string(item);
when PySequence_GetItem() fails
317 			Py_DECREF(item);
318 			if (!s) { goto finish; }
dereferencing NULL (item->ob_refcnt) at _mysql.c:318
found 1 similar trace(s) to this
319 			groups_c[i] = s;
320 		}
321 		groups_c[groupc] = (char *)NULL;
322 	}
323 	/* even though this may block, don't give up the interpreter lock
324 	   so that the server can't be initialized multiple times. */
325 	if (mysql_server_init(cmd_argc, cmd_args_c, groups_c)) {
326 		_mysql_Exception(NULL);
327 		goto finish;
328 	}
329 #endif
330 	ret = Py_None;
331 	Py_INCREF(Py_None);
332 	_mysql_server_init_done = 1;
333   finish:
334 	PyMem_Free(groups_c);
335 	PyMem_Free(cmd_args_c);
336 	return ret;
337 }
338