diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-03-19 14:11:45 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-03-19 21:01:42 +0100 |
commit | 236f3a8e60e05147a37f294774b0c07d40aff36f (patch) | |
tree | 13da5c98cc824630bd4b3e8cf512fe1646086d88 /vcl | |
parent | 109312f4223a986444c589eca51eac7cdeb5ff48 (diff) |
cid#1473818 Use after free
Change-Id: Idd74e0debd12e42ff97d79b56e76cde6fd98aa2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112745
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/generic/printer/cpdmgr.cxx | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/vcl/unx/generic/printer/cpdmgr.cxx b/vcl/unx/generic/printer/cpdmgr.cxx index bebd568330c5..0789ae7e1ca7 100644 --- a/vcl/unx/generic/printer/cpdmgr.cxx +++ b/vcl/unx/generic/printer/cpdmgr.cxx @@ -43,11 +43,11 @@ void CPDManager::onNameAcquired (GDBusConnection *connection, gpointer user_data) { gchar* contents; - GDBusNodeInfo *introspection_data; - // Get Interface for introspection - g_file_get_contents (FRONTEND_INTERFACE, &contents, nullptr, nullptr); - introspection_data = g_dbus_node_info_new_for_xml (contents, nullptr); + if (!g_file_get_contents (FRONTEND_INTERFACE, &contents, nullptr, nullptr)) + return; + + GDBusNodeInfo *introspection_data = g_dbus_node_info_new_for_xml (contents, nullptr); g_dbus_connection_register_object (connection, "/org/libreoffice/PrintDialog", @@ -63,28 +63,29 @@ void CPDManager::onNameAcquired (GDBusConnection *connection, std::vector<std::pair<std::string, gchar*>> backends = current->getTempBackends(); for (auto const& backend : backends) { - GDBusProxy *proxy; // Get Interface for introspection - g_file_get_contents (BACKEND_INTERFACE, &contents, nullptr, nullptr); - introspection_data = g_dbus_node_info_new_for_xml (contents, nullptr); - proxy = g_dbus_proxy_new_sync (connection, - G_DBUS_PROXY_FLAGS_NONE, - introspection_data->interfaces[0], - backend.first.c_str(), - backend.second, - "org.openprinting.PrintBackend", - nullptr, - nullptr); + if (g_file_get_contents(BACKEND_INTERFACE, &contents, nullptr, nullptr)) + { + introspection_data = g_dbus_node_info_new_for_xml (contents, nullptr); + GDBusProxy *proxy = g_dbus_proxy_new_sync (connection, + G_DBUS_PROXY_FLAGS_NONE, + introspection_data->interfaces[0], + backend.first.c_str(), + backend.second, + "org.openprinting.PrintBackend", + nullptr, + nullptr); + g_assert (proxy != nullptr); + g_dbus_proxy_call(proxy, "ActivateBackend", + nullptr, + G_DBUS_CALL_FLAGS_NONE, + -1, nullptr, nullptr, nullptr); + + g_free(contents); + g_object_unref(proxy); + g_dbus_node_info_unref(introspection_data); + } g_free(backend.second); - g_assert (proxy != nullptr); - g_dbus_proxy_call(proxy, "ActivateBackend", - nullptr, - G_DBUS_CALL_FLAGS_NONE, - -1, nullptr, nullptr, nullptr); - - g_free(contents); - g_object_unref(proxy); - g_dbus_node_info_unref(introspection_data); } } |