vcl/unx/generic/printer/cpdmgr.cxx | 49 ++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 24 deletions(-)
New commits: commit 236f3a8e60e05147a37f294774b0c07d40aff36f Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Mar 19 14:11:45 2021 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Mar 19 21:01:42 2021 +0100 cid#1473818 Use after free Change-Id: Idd74e0debd12e42ff97d79b56e76cde6fd98aa2c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112745 Tested-by: Caolán McNamara <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> 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); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits