[Libreoffice-commits] .: Branch 'libreoffice-3-5' - pyuno/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Mon Mar 19 01:30:20 PDT 2012


 pyuno/source/module/pyuno.cxx |   19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

New commits:
commit 8d7726c6a54cd65700f4d3183baef7800aaeced5
Author: David Bolen <db3l.net at gmail.com>
Date:   Fri Mar 16 22:10:24 2012 +0100

    fdo#46926: PyUNO_cmp: return acquired reference
    
    (cherry picked from commit 742dca7366ba6ac3c58b1df6ee548788f4ce24e7)
    
    Signed-off-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx
index 7f5f0b5..b712ae4 100644
--- a/pyuno/source/module/pyuno.cxx
+++ b/pyuno/source/module/pyuno.cxx
@@ -595,6 +595,8 @@ int PyUNO_setattr (PyObject* self, char* name, PyObject* value)
 // ensure object identity and struct equality
 static PyObject* PyUNO_cmp( PyObject *self, PyObject *that, int op )
 {
+    PyObject *result;
+
     if(op != Py_EQ && op != Py_NE)
     {
         PyErr_SetString(PyExc_TypeError, "only '==' and '!=' comparisions are defined");
@@ -602,7 +604,9 @@ static PyObject* PyUNO_cmp( PyObject *self, PyObject *that, int op )
     }
     if( self == that )
     {
-        return (op == Py_EQ ? Py_True : Py_False);
+        result = (op == Py_EQ ? Py_True : Py_False);
+        Py_INCREF(result);
+        return result;
     }
     try
     {
@@ -624,14 +628,18 @@ static PyObject* PyUNO_cmp( PyObject *self, PyObject *that, int op )
                     Reference< XMaterialHolder > xOther( other->members->xInvocation,UNO_QUERY );
                     if( xMe->getMaterial() == xOther->getMaterial() )
                     {
-                        return (op == Py_EQ ? Py_True : Py_False);
+                        result = (op == Py_EQ ? Py_True : Py_False);
+                        Py_INCREF(result);
+                        return result;
                     }
                 }
                 else if( tcMe == com::sun::star::uno::TypeClass_INTERFACE )
                 {
                     if( me->members->wrappedObject == other->members->wrappedObject )
                     {
-                        return (op == Py_EQ ? Py_True : Py_False);
+                        result = (op == Py_EQ ? Py_True : Py_False);
+                        Py_INCREF(result);
+                        return result;
                     }
                 }
             }
@@ -641,7 +649,10 @@ static PyObject* PyUNO_cmp( PyObject *self, PyObject *that, int op )
     {
         raisePyExceptionWithAny( makeAny( e ) );
     }
-    return (op == Py_EQ ? Py_False : Py_True);
+
+    result = (op == Py_EQ ? Py_False : Py_True);
+    Py_INCREF(result);
+    return result;
 }
 
 /* Python 2 has a tp_flags value for rich comparisons.  Python 3 does not (on by default) */


More information about the Libreoffice-commits mailing list