Skip to content

Commit 9fc01a6

Browse files
committedJun 15, 2013
Fix memory leak in QgsFeature sip api
1 parent b6770be commit 9fc01a6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed
 

‎python/core/qgsfeature.sip

+11-4
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,17 @@ typedef QVector<QVariant> QgsAttributes;
2222
// Set the list elements.
2323
for (int i = 0; i < sipCpp->size(); ++i)
2424
{
25-
QVariant* v = new QVariant(sipCpp->at(i));
25+
QVariant* v = new QVariant( sipCpp->at(i) );
2626
PyObject *tobj;
2727

2828
if ( v->isNull() )
2929
{
3030
tobj = Py_None;
31+
delete v;
3132
}
32-
else if ((tobj = sipConvertFromType(v, sipType_QVariant,Py_None)) == NULL)
33+
else if ((tobj = sipConvertFromNewType(v, sipType_QVariant,Py_None)) == NULL)
3334
{
35+
delete v;
3436
return NULL;
3537
}
3638

@@ -200,11 +202,16 @@ class QgsFeature
200202
}
201203
else
202204
{
203-
QVariant* v = new QVariant(attrs[a0]);
205+
QVariant* v = new QVariant(attrs.at(a0));
204206
if ( v->isNull() )
207+
{
208+
delete v;
205209
sipRes = Py_None;
210+
}
206211
else
207-
sipRes = sipConvertFromInstance( v, sipClass_QVariant, Py_None );
212+
{
213+
sipRes = sipConvertFromNewInstance( v, sipClass_QVariant, Py_None );
214+
}
208215
}
209216
%End
210217

0 commit comments

Comments
 (0)