found a resource leak in file socket.c
Ettl Martin
ettl.martin at gmx.de
Tue Jun 30 13:10:04 PDT 2009
> Martin Ettl wrote:
>
> > 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
>
> I think that isn't really a resource leak, as any open file descriptors are
> cclosed on exit by default.
>
> Helge
>
BTW, this is a real resource leak!
See at definition:
http://en.wikipedia.org/wiki/Resource_leak
Best regards
Martin
More information about the cups
mailing list