From 3fcc85bdd771b870f0a884c0b18c4b463100f2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Popelka?= Date: Mon, 8 Mar 2010 17:04:23 +0000 Subject: [PATCH] - Fixed pycups to be more cautious when removing the Connection object from the list (bug #567386). --- ...onfig-printer-cupsconnection-dealloc.patch | 69 +++++++++++++++++++ system-config-printer.spec | 10 ++- 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 system-config-printer-cupsconnection-dealloc.patch diff --git a/system-config-printer-cupsconnection-dealloc.patch b/system-config-printer-cupsconnection-dealloc.patch new file mode 100644 index 0000000..d25f4c4 --- /dev/null +++ b/system-config-printer-cupsconnection-dealloc.patch @@ -0,0 +1,69 @@ +diff -up system-config-printer-1.1.17/pycups-1.9.48/cupsconnection.c.cupsconnection-dealloc system-config-printer-1.1.17/pycups-1.9.48/cupsconnection.c +--- system-config-printer-1.1.17/pycups-1.9.48/cupsconnection.c.cupsconnection-dealloc 2010-03-08 17:06:47.000000000 +0100 ++++ system-config-printer-1.1.17/pycups-1.9.48/cupsconnection.c 2010-03-08 17:06:47.000000000 +0100 +@@ -231,37 +231,43 @@ Connection_dealloc (Connection *self) + { + int i, j; + +- if (NumConnections > 1) +- { +- Connection **new_array = calloc (NumConnections - 1, +- sizeof (Connection *)); ++ for (j = 0; j < NumConnections; j++) ++ if (Connections[j] == self) ++ break; + +- for (i = 0, j = 0; i < NumConnections; i++) ++ if (j < NumConnections) ++ { ++ if (NumConnections > 1) + { +- if (Connections[i] == self) ++ Connection **new_array = calloc (NumConnections - 1, ++ sizeof (Connection *)); ++ ++ if (new_array) + { +- if (!new_array) +- Connections[i] = NULL; ++ int k; ++ for (i = 0, k = 0; i < NumConnections; i++) ++ { ++ if (i == j) ++ continue; + +- continue; +- } ++ new_array[k++] = Connections[i]; ++ } + +- if (new_array) +- new_array[j++] = Connections[i]; ++ free (Connections); ++ Connections = new_array; ++ NumConnections--; ++ } else ++ /* Failed to allocate memory. Just clear out the reference. */ ++ Connections[j] = NULL; + } +- +- if (new_array) { ++ else ++ { ++ /* The only element is the one we no longer need. */ + free (Connections); +- Connections = new_array; +- NumConnections--; ++ Connections = NULL; ++ NumConnections = 0; + } + } +- else +- { +- free (Connections); +- Connections = NULL; +- NumConnections = 0; +- } + + if (self->http) { + debugprintf ("httpClose()\n"); diff --git a/system-config-printer.spec b/system-config-printer.spec index 07b7b10..6dd0883 100644 --- a/system-config-printer.spec +++ b/system-config-printer.spec @@ -7,7 +7,7 @@ Summary: A printer administration tool Name: system-config-printer Version: 1.1.93 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv2+ URL: http://cyberelk.net/tim/software/system-config-printer/ Group: System Environment/Base @@ -22,6 +22,7 @@ Patch2: system-config-printer-lowercase-mfg-mdl.patch Patch3: system-config-printer-import-gobject.patch Patch4: system-config-printer-check-install.patch Patch5: system-config-printer-icon-name.patch +Patch6: system-config-printer-cupsconnection-dealloc.patch BuildRequires: cups-devel >= 1.2 BuildRequires: python-devel >= 2.4 @@ -95,6 +96,9 @@ printers. # Use 'printer' icon name instead of 'gnome-dev-printer'. %patch5 -p1 -b .icon-name +# Fix pycups Connection_dealloc() +%patch6 -p1 -b .cupsconnection-dealloc + %build %configure --with-udev-rules --with-polkit-1 @@ -210,6 +214,10 @@ rm -rf %buildroot exit 0 %changelog +* Mon Mar 8 2010 Jiri Popelka 1.1.93-6 +- Fixed pycups to be more cautious when removing + the Connection object from the list (bug #567386). + * Wed Mar 3 2010 Tim Waugh - 1.1.93-5 - Added comments for all sources and patches. - Ship COPYING files.