dbus: Avoid memory leak on error when signaling PropertiesChanged
put_changed_properties() might fail, e.g., due to memory allocation failure or a failure in a property getter function. Such an error case would have leaked the message iteration container since the call to dbus_message_iter_close_container() would have been skipped. Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
parent
4037c0ac1e
commit
7184e63ced
1 changed files with 30 additions and 16 deletions
|
@ -671,20 +671,27 @@ static void do_send_prop_changed_signal(
|
|||
&interface) ||
|
||||
/* Changed properties dict */
|
||||
!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
||||
"{sv}", &dict_iter) ||
|
||||
!put_changed_properties(obj_dsc, interface, &dict_iter, 0) ||
|
||||
!dbus_message_iter_close_container(&signal_iter, &dict_iter) ||
|
||||
"{sv}", &dict_iter))
|
||||
goto fail;
|
||||
if (!put_changed_properties(obj_dsc, interface, &dict_iter, 0)) {
|
||||
dbus_message_iter_close_container(&signal_iter, &dict_iter);
|
||||
goto fail;
|
||||
}
|
||||
if (!dbus_message_iter_close_container(&signal_iter, &dict_iter) ||
|
||||
/* Invalidated properties array (empty) */
|
||||
!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
||||
"s", &dict_iter) ||
|
||||
!dbus_message_iter_close_container(&signal_iter, &dict_iter)) {
|
||||
wpa_printf(MSG_DEBUG, "dbus: %s: Failed to construct signal",
|
||||
__func__);
|
||||
} else {
|
||||
dbus_connection_send(con, msg, NULL);
|
||||
}
|
||||
!dbus_message_iter_close_container(&signal_iter, &dict_iter))
|
||||
goto fail;
|
||||
|
||||
dbus_connection_send(con, msg, NULL);
|
||||
|
||||
out:
|
||||
dbus_message_unref(msg);
|
||||
return;
|
||||
fail:
|
||||
wpa_printf(MSG_DEBUG, "dbus: %s: Failed to construct signal", __func__);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
|
@ -702,16 +709,23 @@ static void do_send_deprecated_prop_changed_signal(
|
|||
dbus_message_iter_init_append(msg, &signal_iter);
|
||||
|
||||
if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
||||
"{sv}", &dict_iter) ||
|
||||
!put_changed_properties(obj_dsc, interface, &dict_iter, 1) ||
|
||||
!dbus_message_iter_close_container(&signal_iter, &dict_iter)) {
|
||||
wpa_printf(MSG_DEBUG, "dbus: %s: Failed to construct signal",
|
||||
__func__);
|
||||
} else {
|
||||
dbus_connection_send(con, msg, NULL);
|
||||
"{sv}", &dict_iter))
|
||||
goto fail;
|
||||
if (!put_changed_properties(obj_dsc, interface, &dict_iter, 1)) {
|
||||
dbus_message_iter_close_container(&signal_iter, &dict_iter);
|
||||
goto fail;
|
||||
}
|
||||
if (!dbus_message_iter_close_container(&signal_iter, &dict_iter))
|
||||
goto fail;
|
||||
|
||||
dbus_connection_send(con, msg, NULL);
|
||||
|
||||
out:
|
||||
dbus_message_unref(msg);
|
||||
return;
|
||||
fail:
|
||||
wpa_printf(MSG_DEBUG, "dbus: %s: Failed to construct signal", __func__);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue