summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Vignatti <tiago.vignatti@nokia.com>2011-03-29 19:49:32 +0300
committerTiago Vignatti <tiago.vignatti@nokia.com>2011-04-04 15:41:13 +0300
commitac2fac24d8baa56f369f4e54908bc00c2b73a60a (patch)
treeb6822fd80d43822a7719d3f2c915800fdf24c1d1
parentbc123319206930638ef1217922824d586d4ada6d (diff)
xfree86: fix memory leaks in configLayout
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com> Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--hw/xfree86/common/xf86Config.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 4b897a173..7a23253a0 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1485,7 +1485,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
{
XF86ConfAdjacencyPtr adjp;
XF86ConfInactivePtr idp;
- int count = 0;
+ int saved_count, count = 0;
int scrnum;
XF86ConfLayoutPtr l;
MessageType from;
@@ -1553,6 +1553,9 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
scrnum = adjp->adj_scrnum;
if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
X_CONFIG)) {
+ do {
+ free(slp[count].screen);
+ } while(count--);
free(slp);
return FALSE;
}
@@ -1641,6 +1644,10 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
}
}
+ if (!count)
+ saved_count = 1;
+ else
+ saved_count = count;
/*
* Count the number of inactive devices.
*/
@@ -1657,16 +1664,14 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
idp = conf_layout->lay_inactive_lst;
count = 0;
while (idp) {
- if (!configDevice(&gdp[count], idp->inactive_device, FALSE)) {
- free(gdp);
- return FALSE;
- }
+ if (!configDevice(&gdp[count], idp->inactive_device, FALSE))
+ goto bail;
count++;
idp = (XF86ConfInactivePtr)idp->list.next;
}
if (!configInputDevices(conf_layout, servlayoutp))
- return FALSE;
+ goto bail;
servlayoutp->id = conf_layout->lay_identifier;
servlayoutp->screens = slp;
@@ -1675,6 +1680,14 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
from = X_DEFAULT;
return TRUE;
+
+bail:
+ do {
+ free(slp[saved_count].screen);
+ } while(saved_count--);
+ free(slp);
+ free(gdp);
+ return FALSE;
}
/*