connexion leak in cupsext / getPrinters

Bug #1179433 reported by Antoine Monnet on 2013-05-13
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
HPLIP
Undecided
Unassigned

Bug Description

cupsext / getPrinters leaks a server connection on each call :

Ex:

 % strace -f -e trace=connect python
Python 2.7.3 (default, Jan 2 2013, 16:53:07)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cupsext, os
>>> os.listdir('/proc/%d/fd/'%os.getpid())
['0', '1', '2', '3']
>>> cupsext.getPrinters()
connect(4, {sa_family=AF_FILE, path="/var/run/cups/cups.sock"}, 26) = 0
[<cupsext.Printer object at 0xf7477750>, <cupsext.Printer object at 0xf74777f0>, <cupsext.Printer object at 0xf7477868>, <cupsext.Printer object at 0xf7477890>]
>>> os.listdir('/proc/%d/fd/'%os.getpid())
['0', '1', '2', '3', '4', '5']
>>> cupsext.getPrinters()
connect(5, {sa_family=AF_FILE, path="/var/run/cups/cups.sock"}, 26) = 0
[<cupsext.Printer object at 0xf7477778>, <cupsext.Printer object at 0xf7477980>, <cupsext.Printer object at 0xf74779f8>, <cupsext.Printer object at 0xf7477a20>]
>>> os.listdir('/proc/%d/fd/'%os.getpid())
['0', '1', '2', '3', '4', '5', '6']
>>> cupsext.getPrinters()
connect(6, {sa_family=AF_FILE, path="/var/run/cups/cups.sock"}, 26) = 0
[<cupsext.Printer object at 0xf7477908>, <cupsext.Printer object at 0xf7477b10>, <cupsext.Printer object at 0xf7477b88>, <cupsext.Printer object at 0xf7477bb0>]
>>> os.listdir('/proc/%d/fd/'%os.getpid())
['0', '1', '2', '3', '4', '5', '6', '7']
>>> cupsext.getPrinters()
connect(7, {sa_family=AF_FILE, path="/var/run/cups/cups.sock"}, 26) = 0
[<cupsext.Printer object at 0xf7477a98>, <cupsext.Printer object at 0xf7477ca0>, <cupsext.Printer object at 0xf7477d18>, <cupsext.Printer object at 0xf7477d40>]
>>> os.listdir('/proc/%d/fd/'%os.getpid())
['0', '1', '2', '3', '4', '5', '6', '7', '8']

Seems like the same bug was corrected in getPPDList : return before abort label has been commented to let cleanup happens anyway.

Proposing the following 1-liner patch, applying the same solution to getPrinters :

--- cupsext.c 2013-05-13 11:44:36.147287706 +0200
+++ cupsext.c.mod 2013-05-13 11:45:17.215488498 +0200
@@ -448,7 +448,7 @@
                 break;
         }

- return printer_list;
+ //return printer_list;
     }
 abort:
     if ( response != NULL )

Changed in hplip:
status: New → Confirmed
Changed in hplip:
status: Confirmed → Fix Committed
Changed in hplip:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers