[omniORB-dev] [omniORBpy][Bug] Memory leak in minorCodeToString

Moriarty predator777 at gmail.com
Mon Mar 24 12:19:39 GMT 2008


Hi!

I've just found a memory leak in case of catching
CORBA.SystemException in client code.
The bug is in modules/pyomniFunc.cc, pyomni_minorCodeToString:

Discover this lines of code:
    pyrepoId = PyObject_GetAttrString(pyexc, (char*)"_NP_RepositoryId");
.........
    pyminor  = PyObject_GetAttrString(pyexc, (char*)"minor");
.........
    if (!(pyrepoId && PyString_Check(pyrepoId) &&
      pyminor  && (PyInt_Check(pyminor) || PyLong_Check(pyminor)))) {
      Py_INCREF(Py_None);
      return Py_None;
    }
........
    if (str)
      return PyString_FromString(str);
    else {
      Py_INCREF(Py_None);
      return Py_None;
    }

>From Python docs:
  PyObject* PyObject_GetAttr(	PyObject *o, PyObject *attr_name)
    Return value: New reference.

You should call Py_XDECREF(pyrepoId) and Py_XDECREF(pyminor) before
exiting from function.
ALSO, please, review similar plases in omniORBpy wrapper.

-- 
With best wishes && regards, Moriarty



More information about the omniORB-dev mailing list