File: _mysql.c
Function: _mysql_string_literal
Error: memory leak: ob_refcnt of '*s' is 1 too high
1107 static PyObject *
1108 _mysql_string_literal(
1109 	_mysql_ConnectionObject *self,
1110 	PyObject *args)
1111 {
1112 	PyObject *str, *s, *o, *d;
1113 	char *in, *out;
1114 	int len, size, isbytes;
1115 	if (!PyArg_ParseTuple(args, "O|O:string_literal", &o, &d)) return NULL;
when PyArg_ParseTuple() succeeds
taking False path
1116 	// TODO: Would be better to *only* accept bytes here.
1117 	isbytes = PyBytes_Check(o);
when treating unknown struct _typeobject * from _mysql.c:1117 as non-NULL
when considering value == (long int)0 from _mysql.c:1117
1118 	if (isbytes) {
taking False path
1119 		s = o;
1120 	} else if (PyUnicode_Check(o)) {
when treating unknown struct _typeobject * from _mysql.c:1120 as non-NULL
when considering value == (long int)0 from _mysql.c:1120
taking False path
1121 		s = PyUnicode_AsEncodedString(o, "UTF-8", "strict");
1122 	} else {
1123 		s = PyObject_Bytes(o);
when PyObject_Str() succeeds
'*s' was allocated at: 		s = PyObject_Bytes(o);
ob_refcnt is now refs: 1 owned
1124 	}
1125 	if (!s) return NULL;
taking False path
1126 
1127 	in = PyBytes_AS_STRING(s);
1128 	size = PyBytes_GET_SIZE(s);
1129 	str = PyBytes_FromStringAndSize((char *) NULL, size*2+3);
when PyString_FromStringAndSize() succeeds
1130 	if (!str) return PyErr_NoMemory();
taking False path
1131 	out = PyBytes_AS_STRING(str);
1132 #if MYSQL_VERSION_ID < 32321
1133 	len = mysql_escape_string(out+1, in, size);
1134 #else
1135 	len = mysql_real_escape_string(utf8conn, out+1, in, size);
1136 #endif
1137 	*out = *(out+len+1) = '\'';
when treating unknown char * from _mysql.c:1137 as non-NULL
1138 	if (_PyBytes_Resize(&str, len+2) < 0) return NULL;
when considering range: -0x80000000 <= value <= -1
taking True path
1139 	if (!isbytes) {
1140 		Py_DECREF(s);
1141 	}
1142 	return (str);
1143 }

File: _mysql.c
Function: _mysql_string_literal
Error: memory leak: ob_refcnt of '*str.35' is 1 too high
1107 static PyObject *
1108 _mysql_string_literal(
1109 	_mysql_ConnectionObject *self,
1110 	PyObject *args)
1111 {
1112 	PyObject *str, *s, *o, *d;
1113 	char *in, *out;
1114 	int len, size, isbytes;
1115 	if (!PyArg_ParseTuple(args, "O|O:string_literal", &o, &d)) return NULL;
when PyArg_ParseTuple() succeeds
taking False path
1116 	// TODO: Would be better to *only* accept bytes here.
1117 	isbytes = PyBytes_Check(o);
when treating unknown struct _typeobject * from _mysql.c:1117 as non-NULL
when considering value == (long int)0 from _mysql.c:1117
1118 	if (isbytes) {
taking False path
1119 		s = o;
1120 	} else if (PyUnicode_Check(o)) {
when treating unknown struct _typeobject * from _mysql.c:1120 as non-NULL
when considering value == (long int)0 from _mysql.c:1120
taking False path
1121 		s = PyUnicode_AsEncodedString(o, "UTF-8", "strict");
1122 	} else {
1123 		s = PyObject_Bytes(o);
when PyObject_Str() succeeds
1124 	}
1125 	if (!s) return NULL;
taking False path
1126 
1127 	in = PyBytes_AS_STRING(s);
1128 	size = PyBytes_GET_SIZE(s);
1129 	str = PyBytes_FromStringAndSize((char *) NULL, size*2+3);
when PyString_FromStringAndSize() succeeds
'*str.35' was allocated at: 	str = PyBytes_FromStringAndSize((char *) NULL, size*2+3);
ob_refcnt is now refs: 1 owned
1130 	if (!str) return PyErr_NoMemory();
taking False path
1131 	out = PyBytes_AS_STRING(str);
1132 #if MYSQL_VERSION_ID < 32321
1133 	len = mysql_escape_string(out+1, in, size);
1134 #else
1135 	len = mysql_real_escape_string(utf8conn, out+1, in, size);
1136 #endif
1137 	*out = *(out+len+1) = '\'';
when treating unknown char * from _mysql.c:1137 as non-NULL
1138 	if (_PyBytes_Resize(&str, len+2) < 0) return NULL;
when considering range: -0x80000000 <= value <= -1
taking True path
1139 	if (!isbytes) {
1140 		Py_DECREF(s);
1141 	}
1142 	return (str);
1143 }

File: _mysql.c
Function: _mysql_string_literal
Error: returning (PyObject*)NULL without setting an exception
1107 static PyObject *
1108 _mysql_string_literal(
1109 	_mysql_ConnectionObject *self,
1110 	PyObject *args)
1111 {
1112 	PyObject *str, *s, *o, *d;
1113 	char *in, *out;
1114 	int len, size, isbytes;
1115 	if (!PyArg_ParseTuple(args, "O|O:string_literal", &o, &d)) return NULL;
when PyArg_ParseTuple() succeeds
taking False path
1116 	// TODO: Would be better to *only* accept bytes here.
1117 	isbytes = PyBytes_Check(o);
when treating unknown struct _typeobject * from _mysql.c:1117 as non-NULL
when considering value == (long int)0 from _mysql.c:1117
1118 	if (isbytes) {
taking False path
1119 		s = o;
1120 	} else if (PyUnicode_Check(o)) {
when treating unknown struct _typeobject * from _mysql.c:1120 as non-NULL
when considering value == (long int)0 from _mysql.c:1120
taking False path
1121 		s = PyUnicode_AsEncodedString(o, "UTF-8", "strict");
1122 	} else {
1123 		s = PyObject_Bytes(o);
when PyObject_Str() succeeds
1124 	}
1125 	if (!s) return NULL;
taking False path
1126 
1127 	in = PyBytes_AS_STRING(s);
1128 	size = PyBytes_GET_SIZE(s);
1129 	str = PyBytes_FromStringAndSize((char *) NULL, size*2+3);
when PyString_FromStringAndSize() succeeds
1130 	if (!str) return PyErr_NoMemory();
taking False path
1131 	out = PyBytes_AS_STRING(str);
1132 #if MYSQL_VERSION_ID < 32321
1133 	len = mysql_escape_string(out+1, in, size);
1134 #else
1135 	len = mysql_real_escape_string(utf8conn, out+1, in, size);
1136 #endif
1137 	*out = *(out+len+1) = '\'';
when treating unknown char * from _mysql.c:1137 as non-NULL
1138 	if (_PyBytes_Resize(&str, len+2) < 0) return NULL;
when considering range: -0x80000000 <= value <= -1
taking True path
1139 	if (!isbytes) {
1140 		Py_DECREF(s);
1141 	}
1142 	return (str);
1143 }