103 static LDAPMod*
104 Tuple_to_LDAPMod( PyObject* tup, int no_op )
105 {
106 int op;
107 char *type;
108 PyObject *list, *item;
109 LDAPMod *lm = NULL;
110 Py_ssize_t i, len, nstrs;
111
112 if (!PyTuple_Check(tup)) {
when considering range: 1 <= value <= 0x4000000
taking False path
113 PyErr_SetObject(PyExc_TypeError, Py_BuildValue("sO",
114 "expected a tuple", tup));
115 return NULL;
116 }
117
118 if (no_op) {
when considering range: -0x80000000 <= value <= -1
taking True path
119 if (!PyArg_ParseTuple( tup, "sO", &type, &list ))
when _PyArg_ParseTuple_SizeT() succeeds
taking False path
120 return NULL;
121 op = 0;
122 } else {
123 if (!PyArg_ParseTuple( tup, "isO", &op, &type, &list ))
124 return NULL;
125 }
126
127 lm = PyMem_NEW(LDAPMod, 1);
128 if (lm == NULL)
when treating unknown void * from Modules/LDAPObject.c:127 as non-NULL
taking False path
129 goto nomem;
130
131 lm->mod_op = op | LDAP_MOD_BVALUES;
132 lm->mod_bvalues = NULL;
133
134 len = strlen(type);
135 lm->mod_type = PyMem_NEW(char, len + 1);
taking True path
taking True path
taking True path
136 if (lm->mod_type == NULL)
when treating unknown void * from Modules/LDAPObject.c:135 as non-NULL
taking False path
137 goto nomem;
138 memcpy(lm->mod_type, type, len + 1);
139
140 if (list == Py_None) {
taking False path
141 /* None indicates a NULL mod_bvals */
142 } else if (PyString_Check(list)) {
when treating unknown struct _typeobject * from Modules/LDAPObject.c:142 as non-NULL
when considering value == (long int)0 from Modules/LDAPObject.c:142
taking False path
143 /* Single string is a singleton list */
144 lm->mod_bvalues = PyMem_NEW(struct berval *, 2);
145 if (lm->mod_bvalues == NULL)
146 goto nomem;
147 lm->mod_bvalues[0] = PyMem_NEW(struct berval, 1);
148 if (lm->mod_bvalues[0] == NULL)
149 goto nomem;
150 lm->mod_bvalues[1] = NULL;
151 lm->mod_bvalues[0]->bv_len = PyString_Size(list);
152 lm->mod_bvalues[0]->bv_val = PyString_AsString(list);
153 } else if (PySequence_Check(list)) {
when considering range: -0x80000000 <= value <= -1
taking True path
154 nstrs = PySequence_Length(list);
when PySequence_Size() succeeds
155 lm->mod_bvalues = PyMem_NEW(struct berval *, nstrs + 1);
when considering range: 1 <= value <= 0xfffffffffffffff
taking True path
taking True path
taking True path
156 if (lm->mod_bvalues == NULL)
when treating unknown void * from Modules/LDAPObject.c:155 as non-NULL
taking False path
157 goto nomem;
158 for (i = 0; i < nstrs; i++) {
when considering range: 1 <= nstrs <= 0x7fffffffffffffff
taking True path
159 lm->mod_bvalues[i] = PyMem_NEW(struct berval, 1);
160 if (lm->mod_bvalues[i] == NULL)
when treating unknown void * from Modules/LDAPObject.c:159 as non-NULL
taking False path
161 goto nomem;
162 lm->mod_bvalues[i+1] = NULL;
163 item = PySequence_GetItem(list, i);
when PySequence_GetItem() succeeds
164 if (item == NULL)
taking False path
165 goto error;
166 if (!PyString_Check(item)) {
when considering value == (long int)0 from Modules/LDAPObject.c:166
taking True path
167 PyErr_SetObject( PyExc_TypeError, Py_BuildValue( "sO",
when _Py_BuildValue_SizeT() succeeds
calling PyErr_SetObject()
new ref from call to _Py_BuildValue_SizeT allocated at: PyErr_SetObject( PyExc_TypeError, Py_BuildValue( "sO",
ob_refcnt is now refs: 1 + N where N >= 0
ob_refcnt is now refs: 1 + N where N >= 1
168 "expected a string in the list", item));
169 Py_DECREF(item);
taking True path
170 goto error;
171 }
172 lm->mod_bvalues[i]->bv_len = PyString_Size(item);
173 lm->mod_bvalues[i]->bv_val = PyString_AsString(item);
174 Py_DECREF(item);
175 }
176 if (nstrs == 0)
177 lm->mod_bvalues[0] = NULL;
178 }
179
180 return lm;
181
182 nomem:
183 PyErr_NoMemory();
184 error:
185 if (lm)
taking True path
186 LDAPMod_DEL(lm);
187
188 return NULL;
189 }
ob_refcnt of new ref from call to _Py_BuildValue_SizeT is 1 too high
was expecting final ob_refcnt to be N + 0 (for some unknown N)
but final ob_refcnt is N + 1
found 1 similar trace(s) to this