Remove unused DbusError to avoid memory leak. 80/207880/1
authorGaurav Gupta <g.gupta@samsung.com>
Thu, 13 Jun 2019 10:57:07 +0000 (16:27 +0530)
committerGaurav Gupta <g.gupta@samsung.com>
Thu, 13 Jun 2019 11:13:03 +0000 (16:43 +0530)
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

dbus/dbus-transport-kdbus.c

index 4697972..ff29889 100755 (executable)
@@ -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)