[cppcheck] resource leak xf86Configure.c
Daniel Stone
daniel at fooishbar.org
Sat Oct 3 18:10:46 PDT 2009
On Sat, Oct 03, 2009 at 01:56:29PM +0200, Martin Ettl wrote:
> here is another issue (spotted out by cppcheck, a static code analysis tool).
>
> It prints the following warning:
>
> ../xfree86/common/xf86Configure.c,266,possible error,Resource leak: fd
>
> Take a look into file xf86Configure.c at line 266:
>
> ...
> fd = open("/dev/wsmouse", 0);
> if (fd > 0) {
> DFLT_MOUSE_DEV = "/dev/wsmouse";
> DFLT_MOUSE_PROTO = "wsmouse";
> close(fd);
> } else {
> ErrorF("cannot open /dev/wsmouse\n");
> }
> ...
>
> As you can see, the if()-statement is wrong because open returns the filepointer or, in case of an error -1 !! See the attached patch that corrects that issue.
Acked-by: Daniel Stone <daniel at fooishbar.org>
I've merged both of these fixes into ~daniels/xserver.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.x.org/archives/xorg-devel/attachments/20091004/cea2d9a2/attachment.pgp
More information about the xorg-devel
mailing list