Bug 20756

Summary: XkbCopySrvLedInfo has a memory leak
Product: xorg Reporter: Maarten Maathuis <madman2003>
Component: Server/Input/XKBAssignee: Daniel Stone <daniel>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Invert logic. none

Description Maarten Maathuis 2009-03-19 16:25:52 UTC
Rationale:

All the other code treats XkbSLI_IsDefault as a situation where names and maps are standard and therefore not copied (and freed). The logic in this case is inverted.

Patch included.

Valgrind output:

==15856== 253,664 bytes in 595 blocks are indirectly lost in loss record 270 of 273
==15856==    at 0x4C248AD: malloc (vg_replace_malloc.c:207)
==15856==    by 0x44BE85: Xcalloc (utils.c:1091)
==15856==    by 0x4EC881: XkbCopySrvLedInfo (xkbLEDs.c:647)
==15856==    by 0x4D5BC6: DeepCopyDeviceClasses (exevents.c:253)
==15856==    by 0x4D6A88: UpdateDeviceState (exevents.c:693)
==15856==    by 0x4D6ECA: ProcessOtherEvent (exevents.c:925)
==15856==    by 0x4FD42E: ProcessKeyboardEvent (xkbPrKeyEv.c:181)
==15856==    by 0x443B68: mieqProcessDeviceEvent (mieq.c:367)
==15856==    by 0x443C40: mieqProcessInputEvents (mieq.c:427)
==15856==    by 0x451218: ProcessInputEvents (xf86Events.c:177)
==15856==    by 0x4821A0: Dispatch (dispatch.c:354)
==15856==    by 0x427AEC: main (main.c:395)
Comment 1 Maarten Maathuis 2009-03-19 16:26:33 UTC
Created attachment 24059 [details] [review]
Invert logic.

Patch that fixes leak.
Comment 2 Dan Nicholson 2009-03-19 16:29:13 UTC
Could you put that rationale in the commit message? That's what it's for.
Comment 3 Maarten Maathuis 2009-03-19 16:56:59 UTC
I made the patch before writing the bug, so that's why it wasn't in there.
Comment 4 Peter Hutterer 2009-03-22 23:17:00 UTC
Pushed as d698e62690e0a52fa537f1cd792cab7a5b1bafdf, thanks for the patch.

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.