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) ||
|
&interface) ||
|
||||||
/* Changed properties dict */
|
/* Changed properties dict */
|
||||||
!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
||||||
"{sv}", &dict_iter) ||
|
"{sv}", &dict_iter))
|
||||||
!put_changed_properties(obj_dsc, interface, &dict_iter, 0) ||
|
goto fail;
|
||||||
!dbus_message_iter_close_container(&signal_iter, &dict_iter) ||
|
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) */
|
/* Invalidated properties array (empty) */
|
||||||
!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
||||||
"s", &dict_iter) ||
|
"s", &dict_iter) ||
|
||||||
!dbus_message_iter_close_container(&signal_iter, &dict_iter)) {
|
!dbus_message_iter_close_container(&signal_iter, &dict_iter))
|
||||||
wpa_printf(MSG_DEBUG, "dbus: %s: Failed to construct signal",
|
goto fail;
|
||||||
__func__);
|
|
||||||
} else {
|
|
||||||
dbus_connection_send(con, msg, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
dbus_connection_send(con, msg, NULL);
|
||||||
|
|
||||||
|
out:
|
||||||
dbus_message_unref(msg);
|
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);
|
dbus_message_iter_init_append(msg, &signal_iter);
|
||||||
|
|
||||||
if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
|
||||||
"{sv}", &dict_iter) ||
|
"{sv}", &dict_iter))
|
||||||
!put_changed_properties(obj_dsc, interface, &dict_iter, 1) ||
|
goto fail;
|
||||||
!dbus_message_iter_close_container(&signal_iter, &dict_iter)) {
|
if (!put_changed_properties(obj_dsc, interface, &dict_iter, 1)) {
|
||||||
wpa_printf(MSG_DEBUG, "dbus: %s: Failed to construct signal",
|
dbus_message_iter_close_container(&signal_iter, &dict_iter);
|
||||||
__func__);
|
goto fail;
|
||||||
} else {
|
|
||||||
dbus_connection_send(con, msg, NULL);
|
|
||||||
}
|
}
|
||||||
|
if (!dbus_message_iter_close_container(&signal_iter, &dict_iter))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
dbus_connection_send(con, msg, NULL);
|
||||||
|
|
||||||
|
out:
|
||||||
dbus_message_unref(msg);
|
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