[cups.development] found a resource leak in file socket.c

Martin Ettl ettl.martin at gmx.de
Tue Jun 30 11:52:52 PDT 2009


Hi all,

i have checked the sources of cups with the static code analysis tool cppcheck. It found a resource leak in file socket.c at line 259. The tool prints the following output:

 [cups-1.3.10/backend/socket.c:259]: (error) Resource leak: print_fd

Take a look at the sourcecode to line 259:

.....
 if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) == NULL)
  {
    _cupsLangPrintf(stderr, _("ERROR: Unable to locate printer \'%s\'!\n"),
                    hostname);
259    return (CUPS_BACKEND_STOP);
  }
.....

Indeed, the file is never closed. A possible fix could be:

.....
 if ((addrlist = httpAddrGetList(hostname, AF_UNSPEC, portname)) ==NULL)
  {
    _cupsLangPrintf(stderr, _("ERROR: Unable to locate printer\'%s '!\n"),
                    hostname);
    close(print_fd);  
    return (CUPS_BACKEND_STOP);
  }
......


Best regards

Ettl Martin
-- 
Neu: GMX Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate
für nur 19,99 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02





More information about the cups mailing list