Backport a patch from master to fix a crash when getting package history

This commit is contained in:
Richard Hughes 2013-12-03 09:27:52 +00:00
parent a491b9639b
commit e9657c296f
2 changed files with 83 additions and 1 deletions

View File

@ -0,0 +1,74 @@
From 9a6e31aac2ddf6c4bd28c70c60b333e81680ef3c Mon Sep 17 00:00:00 2001
From: Richard Hughes <richard@hughsie.com>
Date: Tue, 3 Dec 2013 09:22:12 +0000
Subject: [PATCH] Do not assert when re-using a PkPackage instance
This fixes commit 8d26af195536cd50f5cd8e6124df4439bb21d287 which added the
additional restriction that the PkPackage couldn't be re-used. This restriction
made the daemon crash when getting package history in gnome-software.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1036837
---
lib/packagekit-glib2/pk-package.c | 5 ++++-
lib/packagekit-glib2/pk-self-test.c | 8 --------
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/lib/packagekit-glib2/pk-package.c b/lib/packagekit-glib2/pk-package.c
index beaad5f..a9560bb 100644
--- a/lib/packagekit-glib2/pk-package.c
+++ b/lib/packagekit-glib2/pk-package.c
@@ -166,7 +166,10 @@ pk_package_set_id (PkPackage *package, const gchar *package_id, GError **error)
g_return_val_if_fail (PK_IS_PACKAGE (package), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- g_return_val_if_fail (priv->package_id == NULL, FALSE);
+
+ /* free old data */
+ g_free (priv->package_id);
+ g_free (priv->package_id_data);
/* copy the package-id into package_id_data, change the ';' into '\0'
* and reference the pointers in the const gchar * array */
diff --git a/lib/packagekit-glib2/pk-self-test.c b/lib/packagekit-glib2/pk-self-test.c
index 753810d..a5e139c 100644
--- a/lib/packagekit-glib2/pk-self-test.c
+++ b/lib/packagekit-glib2/pk-self-test.c
@@ -1937,35 +1937,27 @@ pk_test_package_func (void)
ret = pk_package_set_id (package, "gnome-power-manager", &error);
g_assert_error (error, 1, 0);
g_assert (!ret);
- g_object_unref (package);
g_clear_error (&error);
/* set invalid id (sections) */
- package = pk_package_new ();
ret = pk_package_set_id (package, "gnome-power-manager;0.1.2;i386", &error);
g_assert_error (error, 1, 0);
g_assert (!ret);
- g_object_unref (package);
g_clear_error (&error);
/* set invalid id (sections) */
- package = pk_package_new ();
ret = pk_package_set_id (package, "gnome-power-manager;0.1.2;i386;fedora;dave", &error);
g_assert_error (error, 1, 0);
g_assert (!ret);
- g_object_unref (package);
g_clear_error (&error);
/* set invalid name */
- package = pk_package_new ();
ret = pk_package_set_id (package, ";0.1.2;i386;fedora", &error);
g_assert_error (error, 1, 0);
g_assert (!ret);
- g_object_unref (package);
g_clear_error (&error);
/* set valid name */
- package = pk_package_new ();
ret = pk_package_set_id (package, "gnome-power-manager;0.1.2;i386;fedora", &error);
g_assert_no_error (error);
g_assert (ret);
--
1.8.4.2

View File

@ -6,7 +6,7 @@
Summary: Package management service
Name: PackageKit
Version: 0.8.14
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2+ and LGPLv2+
URL: http://www.packagekit.org
Source0: http://www.packagekit.org/releases/%{name}-%{version}.tar.xz
@ -17,6 +17,9 @@ Patch0: PackageKit-0.3.8-Fedora-Vendor.conf.patch
# Upstreamable? allow use of xulrunner2 for browser-plugin support
Patch4: PackageKit-0.7.4-xulrunner2.patch
# Upstream already
Patch5: 0001-Do-not-assert-when-re-using-a-PkPackage-instance.patch
Requires: %{name}-glib%{?_isa} = %{version}-%{release}
Requires: PackageKit-backend
Requires: shared-mime-info
@ -228,6 +231,7 @@ using PackageKit.
%setup -q
%patch0 -p1 -b .fedora
%patch4 -p1 -b .xulrunner2
%patch5 -p1 -b .no-history-crash
NOCONFIGURE=1 ./autogen.sh
@ -409,6 +413,10 @@ systemctl enable packagekit-offline-update.service &> /dev/null || :
%{_libdir}/pkgconfig/packagekit-plugin.pc
%changelog
* Tue Dec 03 2013 Richard Hughes <rhughes@redhat.com> - 0.8.14-2
- Backport a patch from master to fix a crash when getting package history
- Resolves: #1036837
* Mon Dec 02 2013 Richard Hughes <rhughes@redhat.com> - 0.8.14-1
- New upstream release
- Cache the loaded hawkey sacks to save 280ms for repeat transactions