Skip to content

Commit

Permalink
Fix a memory leak in the DBus file dialog handling
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Sep 25, 2024
1 parent 5446300 commit eafbf5b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions distrho/extra/FileBrowserDialogImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,17 +691,17 @@ bool fileBrowserIdle(const FileBrowserHandle handle)
while (dbus_connection_dispatch(dbuscon) == DBUS_DISPATCH_DATA_REMAINS) {}
dbus_connection_read_write_dispatch(dbuscon, 0);

if (DBusMessage* const message = dbus_connection_pop_message(dbuscon))
if (DBusMessage* const msg = dbus_connection_pop_message(dbuscon))
{
const char* const interface = dbus_message_get_interface(message);
const char* const member = dbus_message_get_member(message);
const char* const interface = dbus_message_get_interface(msg);
const char* const member = dbus_message_get_member(msg);

if (interface != nullptr && std::strcmp(interface, "org.freedesktop.portal.Request") == 0
&& member != nullptr && std::strcmp(member, "Response") == 0)
{
do {
DBusMessageIter iter;
dbus_message_iter_init(message, &iter);
dbus_message_iter_init(msg, &iter);

// starts with uint32 for return/exit code
DISTRHO_SAFE_ASSERT_BREAK(dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_UINT32);
Expand Down Expand Up @@ -813,6 +813,8 @@ bool fileBrowserIdle(const FileBrowserHandle handle)
if (handle->selectedFile == nullptr)
handle->selectedFile = kSelectedFileCancelled;
}

dbus_message_unref(msg);
}
}
#endif
Expand Down

0 comments on commit eafbf5b

Please sign in to comment.