Bug 50281 - Xorg-server memory leaks found with cppcheck
Summary: Xorg-server memory leaks found with cppcheck
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/General (show other bugs)
Version: git
Hardware: All All
: high critical
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL: http://cgit.freedesktop.org/xorg/xser...
Whiteboard: 2012BRB_Reviewed
Depends on:
Blocks: xserver-1.14
  Show dependency treegraph
Reported: 2012-05-23 06:49 UTC by Eduard
Modified: 2014-11-17 20:15 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Description Eduard 2012-05-23 06:49:40 UTC
found in xorg-server-

detected with cppcheck

[Xi/xiproperty.c:734]: (error) Memory leak: new_value.data
[config/wscons.c:175]: (error) Memory leak: dev.config_info
[config/wscons.c:209]: (error) Memory leak: dev.config_info
[glx/glxdri.c:639]: (error) Memory leak: context
[glx/glxdri2.c:700]: (error) Memory leak: screen
[hw/dmx/config/dmxcompat.c:231]: (error) Resource leak: str
[hw/dmx/dmxfont.c:408]: (error) Memory leak: goodfps
[hw/dmx/glxProxy/glxcmds.c:1981]: (error) Memory leak: pGlxPixmap.be_xids
[hw/dmx/input/dmxmotion.c:149]: (error) Memory leak: dmxLocal.history
[hw/kdrive/src/kxv.c:547]: (error) Memory leak: pat.name
[hw/kdrive/src/kxv.c:547]: (error) Memory leak: pe.name
[hw/xfree86/common/xf86sbusBus.c:647]: (error) Memory leak: data
[hw/xfree86/os-support/bus/Sbus.c:621]: (error) Memory leak: name
[hw/xfree86/utils/gtf/gtf.c:695]: (error) Memory leak: m
[hw/xquartz/xpr/x-list.c:103]: (error) Memory leak: b
[hw/xwin/glx/indirect.c:2396]: (error) Memory leak: result
Comment 1 Jeremy Huddleston Sequoia 2012-05-23 10:10:21 UTC
There is no data to support this being a regression, so removing that keyword and the block on 1.12.

I have not audited the others, but the XQuartz one is not a leak.
Comment 2 Eduard 2012-05-23 11:49:49 UTC
yes, you are right in case xquartz.
i checked other files:

// glx/glxdri.c:639, function __glXDRIscreenCreateContext

should be every time in case return NULL:


// glx/glxdri2.c:700, function __glXDRIscreenProbe

should be every time in case return NULL:


// hw/dmx/config/dmxcompat.c:231, function dmxVDLRead
FILE *str;

must be closed before return

// hw/dmx/dmxfont.c:408, function dmxBELoadFont
after all operations with goodfps we must have free(goodfps); 
name_atom = MakeAtom("FONT", 4, TRUE);

// hw/dmx/glxProxy/glxcmds.c:1981 , function CreateGLXPixmap
if we do free(pGlxPixmap), we must call free(pGlxPixmap.be_xids) too 

// hw/xfree86/common/xf86sbusBus.c:647, function xf86SbusCmapLoadPalette
if (!cmap) return; 
change to 
if (!cmap){

// hw/xfree86/os-support/bus/Sbus.c:621, function sparcPromPathname2Node
if we return from function, data should be removed from memory 

other messages you can ignore, sorry for the mistakes
Comment 3 Alan Coopersmith 2013-02-10 20:42:04 UTC
Send patches for 5 of the 7 to xorg-devel for review.

Still waiting for someone else to fix:

// hw/dmx/dmxfont.c:408, function dmxBELoadFont
// hw/dmx/glxProxy/glxcmds.c:1981 , function CreateGLXPixmap
Comment 4 Alan Coopersmith 2013-06-01 01:13:55 UTC
Those 5 are now pulled into the xserver master branch:

Leaving the bug open until someone picks up the last two.
Comment 5 Adam Jackson 2014-11-17 20:15:23 UTC
commit d9e99edd4dcf109492abdaa73ccf8f29d5bfd159
Author: Adam Jackson <ajax@redhat.com>
Date:   Wed Apr 30 13:49:06 2014 -0400

    glxproxy: Fix memory leak on error path in CreateGLXPixmap (#50281) (v2)
    v2: Fix another path spotted by keithp
    Signed-off-by: Adam Jackson <ajax@redhat.com>
    Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Keith Packard <keithp@keithp.com>

commit dff1f5e1a9608eda2992fc9e3304edee7b5bee9b
Author: Adam Jackson <ajax@redhat.com>
Date:   Wed Apr 30 13:49:05 2014 -0400

    dmx: Fix memory leak in dmxBELoadFont (#50281)
    Signed-off-by: Adam Jackson <ajax@redhat.com>
    Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
    Signed-off-by: Keith Packard <keithp@keithp.com>

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.