dbus/python dbus_bindings.pyx,1.7,1.8
John Palmieri
johnp at freedesktop.org
Mon Sep 26 15:12:20 PDT 2005
Update of /cvs/dbus/dbus/python
In directory gabe:/tmp/cvs-serv31850/python
Modified Files:
dbus_bindings.pyx
Log Message:
* dbus/Python.pyx: Fixed memory leaks when throwing errors.
We now copy the message from a DBusError and then free
the error object befor throwing the error
Index: dbus_bindings.pyx
===================================================================
RCS file: /cvs/dbus/dbus/python/dbus_bindings.pyx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- dbus_bindings.pyx 1 Sep 2005 01:22:06 -0000 1.7
+++ dbus_bindings.pyx 26 Sep 2005 22:12:17 -0000 1.8
@@ -261,7 +261,9 @@
self.conn = dbus_connection_open(address,
&error)
if dbus_error_is_set(&error):
- raise DBusException, error.message
+ message = error.message
+ dbus_error_free (&error)
+ raise DBusException, message
def __dealloc__(self):
if self.conn != NULL:
@@ -348,12 +350,9 @@
def send_with_reply(self, Message message, timeout_milliseconds):
cdef dbus_bool_t retval
cdef DBusPendingCall *cpending_call
- cdef DBusError error
cdef DBusMessage *msg
cdef PendingCall pending_call
- dbus_error_init(&error)
-
cpending_call = NULL
msg = message._get_msg()
@@ -363,9 +362,6 @@
&cpending_call,
timeout_milliseconds)
- if dbus_error_is_set(&error):
- raise DBusException, error.message
-
if (cpending_call != NULL):
pending_call = PendingCall()
pending_call.__cinit__(cpending_call)
@@ -392,7 +388,9 @@
&error)
if dbus_error_is_set(&error):
- raise DBusException, error.message
+ message = error.message
+ dbus_error_free (&error)
+ raise DBusException, message
if retval == NULL:
raise AssertionError
@@ -1487,7 +1485,9 @@
self.server = dbus_server_listen(address,
&error)
if dbus_error_is_set(&error):
- raise DBusException, error.message
+ message = error.message
+ dbus_error_free (&error)
+ raise DBusException, message
def disconnect(self):
dbus_server_disconnect(self.server)
@@ -1526,7 +1526,9 @@
&error)
if dbus_error_is_set(&error):
- raise DBusException, error.message
+ message = error.message
+ dbus_error_free(&error)
+ raise DBusException, message
conn = Connection()
conn.__cinit__(None, connection)
@@ -1547,7 +1549,10 @@
retval = dbus_bus_get_unix_user(conn, service_name, &error)
if dbus_error_is_set(&error):
- raise DBusException, error.message
+ message = error.message
+ dbus_error_free(&error)
+ raise DBusException, message
+
return retval
#These are defines, not enums so they aren't auto generated
@@ -1565,6 +1570,11 @@
retval = dbus_bus_start_service_by_name(conn, service_name, flags, &results, &error)
+ if dbus_error_is_set(&error):
+ message = error.message
+ dbus_error_free(&error)
+ raise DBusException, message
+
return (retval, results)
def bus_register(Connection connection):
@@ -1577,7 +1587,9 @@
retval = dbus_bus_register(conn,
&error)
if dbus_error_is_set(&error):
- raise DBusException, error.message
+ message = error.message
+ dbus_error_free(&error)
+ raise DBusException, message
return retval
@@ -1596,7 +1608,10 @@
flags,
&error)
if dbus_error_is_set(&error):
- raise DBusException, error.message
+ message = error.message
+ dbus_error_free(&error)
+ raise DBusException, message
+
return retval
def bus_name_has_owner(Connection connection, service_name):
@@ -1610,7 +1625,10 @@
service_name,
&error)
if dbus_error_is_set(&error):
- raise DBusException, error.message
+ message = error.message
+ dbus_error_free(&error)
+ raise DBusException, message
+
return retval
def bus_add_match(Connection connection, rule):
@@ -1623,7 +1641,9 @@
dbus_bus_add_match (conn, rule, &error)
if dbus_error_is_set(&error):
- raise DBusException, error.message
+ message = error.message
+ dbus_error_free(&error)
+ raise DBusException, message
def bus_remove_match(Connection connection, rule):
cdef DBusError error
@@ -1635,5 +1655,7 @@
dbus_bus_remove_match (conn, rule, &error)
if dbus_error_is_set(&error):
- raise DBusException, error.message
+ message = error.message
+ dbus_error_free(&error)
+ raise DBusException, message
More information about the dbus-commit
mailing list