51cfb8f
From e30c1985edd72af7e32b8b23b82cb8bcfb886f79 Mon Sep 17 00:00:00 2001
51cfb8f
From: Tanu Kaskinen <tanuk@iki.fi>
51cfb8f
Date: Thu, 2 Jan 2020 10:13:09 +0200
51cfb8f
Subject: [PATCH] Fix ustring initialization from a NULL pointer
51cfb8f
51cfb8f
The packages vector was initialized from a and b, but b is sometimes
51cfb8f
NULL. Glib::ustring can't be initialized from a NULL pointer, so the
51cfb8f
initialization crashed.
51cfb8f
51cfb8f
This bug was introduced by the dbus-glib to gdbus conversion in commit
51cfb8f
b8246d3f9b308770a49861cd2dea4d06cd88554e.
51cfb8f
51cfb8f
Fixes: https://gitlab.freedesktop.org/pulseaudio/paprefs/issues/4
51cfb8f
---
51cfb8f
 src/paprefs.cc | 5 ++++-
51cfb8f
 1 file changed, 4 insertions(+), 1 deletion(-)
51cfb8f
51cfb8f
diff --git a/src/paprefs.cc b/src/paprefs.cc
51cfb8f
index af6d885..1c2c390 100644
51cfb8f
--- a/src/paprefs.cc
51cfb8f
+++ b/src/paprefs.cc
51cfb8f
@@ -343,7 +343,10 @@ void MainWindow::showInstallButton(Gtk::Button *button, bool available) {
51cfb8f
 
51cfb8f
 void MainWindow::installFiles(const char *a, const char *b = NULL) {
51cfb8f
     Glib::RefPtr<Gio::DBus::Proxy> proxy;
51cfb8f
-    const std::vector<Glib::ustring> packages = {a, b};
51cfb8f
+    std::vector<Glib::ustring> packages = {a};
51cfb8f
+
51cfb8f
+    if (b)
51cfb8f
+        packages.push_back(Glib::ustring(b));
51cfb8f
 
51cfb8f
     proxy = Gio::DBus::Proxy::create_for_bus_sync(Gio::DBus::BusType::BUS_TYPE_SESSION,
51cfb8f
                                                       "org.freedesktop.PackageKit",
51cfb8f
-- 
51cfb8f
2.26.1
51cfb8f