Blob Blame History Raw
From e30c1985edd72af7e32b8b23b82cb8bcfb886f79 Mon Sep 17 00:00:00 2001
From: Tanu Kaskinen <tanuk@iki.fi>
Date: Thu, 2 Jan 2020 10:13:09 +0200
Subject: [PATCH] Fix ustring initialization from a NULL pointer

The packages vector was initialized from a and b, but b is sometimes
NULL. Glib::ustring can't be initialized from a NULL pointer, so the
initialization crashed.

This bug was introduced by the dbus-glib to gdbus conversion in commit
b8246d3f9b308770a49861cd2dea4d06cd88554e.

Fixes: https://gitlab.freedesktop.org/pulseaudio/paprefs/issues/4
---
 src/paprefs.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/paprefs.cc b/src/paprefs.cc
index af6d885..1c2c390 100644
--- a/src/paprefs.cc
+++ b/src/paprefs.cc
@@ -343,7 +343,10 @@ void MainWindow::showInstallButton(Gtk::Button *button, bool available) {
 
 void MainWindow::installFiles(const char *a, const char *b = NULL) {
     Glib::RefPtr<Gio::DBus::Proxy> proxy;
-    const std::vector<Glib::ustring> packages = {a, b};
+    std::vector<Glib::ustring> packages = {a};
+
+    if (b)
+        packages.push_back(Glib::ustring(b));
 
     proxy = Gio::DBus::Proxy::create_for_bus_sync(Gio::DBus::BusType::BUS_TYPE_SESSION,
                                                       "org.freedesktop.PackageKit",
-- 
2.26.1