xfree86: plug a memory leak in xf86LoadModules.

LoadModule() returns the only reference to a fresh piece of memory (a
ModuleDescPtr). Sadly, xf86LoadModules dropped the return value on the floor
leaking memory for each module it loaded.

Signed-off-by: Peter Hutterer <peter@cs.unisa.edu.au>
This commit is contained in:
Arjan van de Ven 2008-02-18 18:13:10 +10:30 committed by Peter Hutterer
parent 6dc71f6b2c
commit 3abce3ea2b

View File

@ -1922,6 +1922,7 @@ xf86LoadModules(char **list, pointer *optlist)
int i;
char *name;
Bool failed = FALSE;
ModuleDescPtr desc;
if (!list)
return TRUE;
@ -1945,11 +1946,15 @@ xf86LoadModules(char **list, pointer *optlist)
else
opt = NULL;
if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) {
desc = LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj,
&errmin);
if (!desc) {
LoaderErrorMsg(NULL, name, errmaj, errmin);
failed = TRUE;
}
xfree(name);
xfree(desc->name);
xfree(desc);
}
return !failed;
}