cli: avoid coverity warning in do_connection_down()

Error: USE_AFTER_FREE (CWE-416): [#def729] [important]
    NetworkManager-1.31.90/src/nmcli/connections.c:3288: freed_arg: "connection_cb_info_finish" frees "info".
    NetworkManager-1.31.90/src/nmcli/connections.c:3287: pass_freed_arg: Passing freed pointer "info" as an argument to "g_signal_handlers_disconnect_matched".
    # 3285|
    # 3286|               if (info) {
    # 3287|->                 g_signal_handlers_disconnect_by_func(active, down_active_connection_state_cb, info);
    # 3288|                   connection_cb_info_finish(info, active);
    # 3289|               }
This commit is contained in:
Thomas Haller 2021-06-08 13:35:58 +02:00
parent 7825609f1f
commit 627503ad86
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -3284,7 +3284,13 @@ do_connection_down(const NMCCommand *cmd, NmCli *nmc, int argc, const char *cons
g_clear_error(&error);
if (info) {
/* coverity thinks that info might be freed already while we still iterate
* the loop. But it cannot, because connection_cb_info_finish() only does some
* kind of ref-counting that ensures info stays alive long enough. */
/* coverity[pass_freed_arg] */
g_signal_handlers_disconnect_by_func(active, down_active_connection_state_cb, info);
connection_cb_info_finish(info, active);
}
}