Hi friends,
i run cppcheck (a static code analysis tool;
http://sourceforge.net/projects/cppcheck/) against the sources of xorg-server
1.7.0. I created a patch to clean up the following issues (see attachments):
../xfree86/os-support/linux/lnx_apm.c,183,Error,Resource leak: fd
../xfree86/dixmods/extmod/xf86vmode.c,123,Error,Invalid number of character
((). Can't process file.
../xfree86/dri/dri.c,1694,Error,Possible null pointer dereference: newContext -
otherwise it is redundant to check if newContext is null at line 1704
../xwin/winshadgdi.c,288,Error,Deallocating a deallocated pointer: pbmih
../kdrive/sdl/sdl.c,98,Error,Memory leak: sdlDriver
../xquartz/mach-startup/bundle-main.c,304,Error,Memory leak: handoff_data
../xquartz/xpr/x-list.c,106,Error,Memory leak: b
../xnest/Keyboard.c,210,Error,Possible null pointer dereference: pDev -
otherwise it is redundant to check if pDev is null at line 215
../dmx/config/dmxcompat.c,235,Error,Resource leak: str
../dmx/input/lnx-keyboard.c,426,Error,Resource leak: fd
../../xkb/ddxList.c,217,possible error,Resource leak: in
../../xkb/ddxList.c,217,Error,Resource leak: in
../../glx/glxdri.c,512,possible style,Division with signed and unsigned
operators
../../glx/glxdri.c,558,possible style,Division with signed and unsigned
operators
../../exa/exa_mixed.c,107,Error,Possible null pointer dereference: pPixmap -
otherwise it is redundant to check if pPixmap is null at line 112
../../exa/exa_driver.c,125,Error,Possible null pointer dereference: pPixmap -
otherwise it is redundant to check if pPixmap is null at line 130
../../exa/exa_classic.c,147,Error,Possible null pointer dereference: pPixmap -
otherwise it is redundant to check if pPixmap is null at line 152
Best regards
Martin
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
--
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser
--
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser
diff --git a/exa/exa_classic.c b/exa/exa_classic.c
index 1eff570..c9c7534 100644
--- a/exa/exa_classic.c
+++ b/exa/exa_classic.c
@@ -144,14 +144,14 @@ Bool
exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, int depth,
int bitsPerPixel, int devKind, pointer pPixData)
{
+ if (!pPixmap)
+ return FALSE;
+
ScreenPtr pScreen = pPixmap->drawable.pScreen;
ExaScreenPrivPtr pExaScr;
ExaPixmapPrivPtr pExaPixmap;
Bool ret;
- if (!pPixmap)
- return FALSE;
-
pExaScr = ExaGetScreenPriv(pScreen);
pExaPixmap = ExaGetPixmapPriv(pPixmap);
diff --git a/exa/exa_driver.c b/exa/exa_driver.c
index 9703695..db885e5 100644
--- a/exa/exa_driver.c
+++ b/exa/exa_driver.c
@@ -122,14 +122,14 @@ Bool
exaModifyPixmapHeader_driver(PixmapPtr pPixmap, int width, int height, int depth,
int bitsPerPixel, int devKind, pointer pPixData)
{
+ if (!pPixmap)
+ return FALSE;
+
ScreenPtr pScreen = pPixmap->drawable.pScreen;
ExaScreenPrivPtr pExaScr;
ExaPixmapPrivPtr pExaPixmap;
Bool ret;
- if (!pPixmap)
- return FALSE;
-
pExaScr = ExaGetScreenPriv(pScreen);
pExaPixmap = ExaGetPixmapPriv(pPixmap);
diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c
index 167ffa9..0b6f8d9 100644
--- a/exa/exa_mixed.c
+++ b/exa/exa_mixed.c
@@ -104,14 +104,14 @@ Bool
exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth,
int bitsPerPixel, int devKind, pointer pPixData)
{
+ if (!pPixmap)
+ return FALSE;
+
ScreenPtr pScreen = pPixmap->drawable.pScreen;
ExaScreenPrivPtr pExaScr;
ExaPixmapPrivPtr pExaPixmap;
Bool ret, is_offscreen;
- if (!pPixmap)
- return FALSE;
-
pExaScr = ExaGetScreenPriv(pScreen);
pExaPixmap = ExaGetPixmapPriv(pPixmap);
diff --git a/hw/dmx/config/dmxcompat.c b/hw/dmx/config/dmxcompat.c
index b4190ff..2fdad01 100644
--- a/hw/dmx/config/dmxcompat.c
+++ b/hw/dmx/config/dmxcompat.c
@@ -232,5 +232,6 @@ DMXConfigEntryPtr dmxVDLRead(const char *filename)
break;
}
}
+ fclose(str);
return entry;
}
diff --git a/hw/dmx/input/lnx-keyboard.c b/hw/dmx/input/lnx-keyboard.c
index 939a32f..5ad8127 100644
--- a/hw/dmx/input/lnx-keyboard.c
+++ b/hw/dmx/input/lnx-keyboard.c
@@ -422,6 +422,7 @@ static int kbdLinuxGetFreeVTNumber(void)
strerror(errno));
if (ioctl(fd, VT_OPENQRY, &vtno) < 0 || vtno < 0)
FATAL0("kbdLinuxGetFreeVTNumber: Cannot find a free VT\n");
+ close(fd);
return vtno;
}
diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index 4920115..b07810a 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -120,7 +120,7 @@ static int XF86VidModeEventBase = 0;
static void SXF86VidModeNotifyEvent();
xXF86VidModeNotifyEvent * /* from */,
xXF86VidModeNotifyEvent * /* to */
-);
+
static RESTYPE EventType; /* resource type for event masks */
diff --git a/hw/xfree86/os-support/linux/lnx_apm.c b/hw/xfree86/os-support/linux/lnx_apm.c
index 4ccc7d6..b70ddc8 100644
--- a/hw/xfree86/os-support/linux/lnx_apm.c
+++ b/hw/xfree86/os-support/linux/lnx_apm.c
@@ -180,6 +180,8 @@ lnxAPMOpen(void)
xf86MsgVerb(X_INFO,3,"Open APM successful\n");
return lnxCloseAPM;
}
+ // cppcheck warned about a missing close(fd); now it's fixed
+ close(fd);
return NULL;
}
diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c
index 1835c70..03a2725 100644
--- a/hw/xnest/Keyboard.c
+++ b/hw/xnest/Keyboard.c
@@ -206,15 +206,16 @@ LegalModifier(unsigned int key, DeviceIntPtr pDev)
void
xnestUpdateModifierState(unsigned int state)
{
+
+ if (!pDev)
+ return;
+
DeviceIntPtr pDev = xnestKeyboardDevice;
KeyClassPtr keyc = pDev->key;
int i;
CARD8 mask;
int xkb_state;
- if (!pDev)
- return;
-
xkb_state = XkbStateFieldFromRec(&pDev->key->xkbInfo->state);
state = state & 0xff;
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 917bbaf..ef6d807 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -300,7 +300,9 @@ kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename)
}
handoff_data->fd = create_socket(handoff_data->filename);
- if(!handoff_data->fd) {
+ if(!handoff_data->fd)
+ {
+ free(handoff_data);
return KERN_FAILURE;
}
diff --git a/hw/xwin/winshadgdi.c b/hw/xwin/winshadgdi.c
index d38e4f7..625e9e8 100644
--- a/hw/xwin/winshadgdi.c
+++ b/hw/xwin/winshadgdi.c
@@ -280,7 +280,7 @@ winQueryRGBBitsAndMasks (ScreenPtr pScreen)
else
{
ErrorF ("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n");
- free (pbmih);
+ //free (pbmih);
fReturn = FALSE;
}
diff --git a/xkb/ddxList.c b/xkb/ddxList.c
index 3ff3d81..a5438a5 100644
--- a/xkb/ddxList.c
+++ b/xkb/ddxList.c
@@ -214,7 +214,10 @@ char tmpname[PATH_MAX];
}
buf = xalloc(PATH_MAX * sizeof(char));
if (!buf)
+ {
+ fclose(in);
return BadAlloc;
+ }
while ((status==Success)&&((tmp=fgets(buf,PATH_MAX,in))!=NULL)) {
unsigned flags;
register unsigned int i;
_______________________________________________
xorg-devel mailing list
[email protected]
http://lists.x.org/mailman/listinfo/xorg-devel