Invalid memory operation in _wrap_new_ComboBox

Hello,

I think there is a problem in the ComboBox constructor
(at least), when nothing is passed for the "choice" parameter.

(I add the items dynamically, after the control's creation)

The problem is that in this case, the "arg6" variable is set
to the address of a local variable (arg6_defvalue).

This seems OK, but after the C++ call,
there is the command:
        if (arg6) delete arg6;

which is invalid in this case (it was not allocated by a 'new').

Other optional arguments have a slightly different cleanup code,
like:
        if (temp3) delete arg3;

A bad %typemap maybe?

I suggest to change the %typemap for wxArrayString&,
and make it more like the wxString& typemap by adding a
temp variable :
(disclaimer: I did not test):

--(snip)--------------
//---------------------------------------------------------------------------
// Typemap for wxArrayString from Python sequence objects

%typemap(in) wxArrayString& (bool temp=False) {
    if (! PySequence_Check($input)) {
        PyErr_SetString(PyExc_TypeError, "Sequence of strings expected.");
        SWIG_fail;
    }
    $1 = new wxArrayString;
    temp = True;
    int i, len=PySequence_Length($input);
    for (i=0; i<len; i++) {
        PyObject* item = PySequence_GetItem($input, i);
%#if wxUSE_UNICODE
        PyObject* str = PyObject_Unicode(item);
%#else
        PyObject* str = PyObject_Str(item);
%#endif
        $1->Add(Py2wxString(str));
        Py_DECREF(item);
        Py_DECREF(str);
    }
}

%typemap(freearg) wxArrayString& {
    if (temp$argnum) delete $1;
}

--(snip)--------------

And the same for wxArrayInt!

···

--
Amaury Forgeot d'Arc

A bad %typemap maybe?

Just one that has never been used with a default arg before :wink:

I suggest to change the %typemap for wxArrayString&,
and make it more like the wxString& typemap by adding a
temp variable :
(disclaimer: I did not test):

Thanks, it is correct. I'll check in reswigged files later today.

···

amaury.forgeotdarc@ubitrade.com wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!