diff options
author | Gaurav Gupta <g.gupta@samsung.com> | 2019-06-13 16:27:07 +0530 |
---|---|---|
committer | Gaurav Gupta <g.gupta@samsung.com> | 2019-06-13 16:43:03 +0530 |
commit | acedf6f40d6eaa405ac6cb390863b0c216e0543a (patch) | |
tree | 6747e7336be2dcc32a61ec2a4b23ff0802ff7e63 | |
parent | 4afc3d948a181b0eab55436b22f72ba5d33d8efb (diff) | |
download | dbus-acedf6f40d6eaa405ac6cb390863b0c216e0543a.tar.gz dbus-acedf6f40d6eaa405ac6cb390863b0c216e0543a.tar.bz2 dbus-acedf6f40d6eaa405ac6cb390863b0c216e0543a.zip |
Remove unused DbusError to avoid memory leak.
Pass NULL as error argument to avoid setting error string in dbus_validate_bus_name(), thus avoid possible memory leak.
We expect the name to be valid bus name (utf8) as it is fetched from the connection.
It will also optimize stack usage as "local_error" variable & dbus_error_init() function are called in for loop.
Other fix could be to check free "error" if it is set.
Signed-off-by: Gaurav Gupta <g.gupta@samsung.com>
Reviewed-by: Himanshu Maithani <himanshu.m@samsung.com>
Change-Id: I773211edd76b6591369bbaae5464971894481a28
-rwxr-xr-x | dbus/dbus-transport-kdbus.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/dbus/dbus-transport-kdbus.c b/dbus/dbus-transport-kdbus.c index 4697972f..ff29889d 100755 --- a/dbus/dbus-transport-kdbus.c +++ b/dbus/dbus-transport-kdbus.c @@ -2214,11 +2214,9 @@ reply_listNames (DBusTransportKdbus *transport, { if (item->type == KDBUS_ITEM_OWNED_NAME) { - DBusError local_error; char *name_ptr = item->name.name; - dbus_error_init ( &local_error ); - if (!dbus_validate_bus_name (name_ptr, &local_error)) + if (!dbus_validate_bus_name (name_ptr, NULL)) continue; if (flags & KDBUS_LIST_QUEUED) |