Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

free-nonheap-object produced from InstanceHandle.i #50

Open
iurii-provizio opened this issue Mar 30, 2023 · 0 comments
Open

free-nonheap-object produced from InstanceHandle.i #50

iurii-provizio opened this issue Mar 30, 2023 · 0 comments

Comments

@iurii-provizio
Copy link

Dear eProsima,

Current (main) version of Fast-DDS-python produces a SWIG wrapper with a genuine deletion of a stack object:

SWIGINTERN PyObject *_wrap_delete_InstanceHandleValue_t(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
  PyObject *resultobj = 0;
  eprosima::fastrtps::rtps::InstanceHandleValue_t *arg1 = (eprosima::fastrtps::rtps::InstanceHandleValue_t *) 0 ;
  eprosima::fastrtps::rtps::InstanceHandleValue_t temp1 ;
  PyObject *swig_obj[1] ;
  
  if (!args) SWIG_fail;
  swig_obj[0] = args;
  {
    if (PyTuple_Check(swig_obj[0]))
    {
      eprosima::fastrtps::rtps::octet* buf = temp1;
      if (!PyArg_ParseTuple(swig_obj[0], "BBBBBBBBBBBBBBBB",
          buf, buf+1, buf+2, buf+3, buf+4, buf+5, buf+6, buf+7, buf+8,
          buf+9, buf+10, buf+11, buf+12, buf+13, buf+14, buf+15))
      {
        PyErr_SetString(PyExc_TypeError, "tuple must have 16 elements");
        SWIG_fail;
      }
      arg1 = &temp1;
    }
    else
    {
      PyErr_SetString(PyExc_TypeError, "expected a tuple.");
      SWIG_fail;
    }
  }
  {
    try {
      {
        SWIG_PYTHON_THREAD_BEGIN_ALLOW;
        delete arg1;
        SWIG_PYTHON_THREAD_END_ALLOW;
      } 
    }
    catch (Swig::DirectorException &e) {
      SWIG_fail; 
    }
  }
  resultobj = SWIG_Py_Void();
  return resultobj;
fail:
  return NULL;
}

eprosima::fastrtps::rtps::InstanceHandleValue_t temp1 ;
...
arg1 = &temp1;
...
delete arg1;

It's coming from fastdds_python/src/swig/fastdds/rtps/common/InstanceHandle.i:

%typemap(in) eprosima::fastrtps::rtps::InstanceHandleValue_t*(eprosima::fastrtps::rtps::InstanceHandleValue_t temp)
{
    if (PyTuple_Check($input))
    {
        eprosima::fastrtps::rtps::octet* buf = temp;
        if (!PyArg_ParseTuple($input, "BBBBBBBBBBBBBBBB",
                    buf, buf+1, buf+2, buf+3, buf+4, buf+5, buf+6, buf+7, buf+8,
                    buf+9, buf+10, buf+11, buf+12, buf+13, buf+14, buf+15))
        {
            PyErr_SetString(PyExc_TypeError, "tuple must have 16 elements");
            SWIG_fail;
        }
        $1 = &temp;
    }
    else
    {
        PyErr_SetString(PyExc_TypeError, "expected a tuple.");
        SWIG_fail;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant