[patch] fix another module loader memory leak
Arjan van de Ven
arjan at infradead.org
Tue Feb 12 10:53:11 PST 2008
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.
--- hw/xfree86/common/xf86Init.c~ 2008-02-11 12:08:38.000000000 +0100
+++ hw/xfree86/common/xf86Init.c 2008-02-11 12:08:38.000000000 +0100
@@ -1820,6 +1820,7 @@ xf86LoadModules(char **list, pointer *op
int i;
char *name;
Bool failed = FALSE;
+ ModuleDescPtr *desc;
if (!list)
return TRUE;
@@ -1842,11 +1843,15 @@ xf86LoadModules(char **list, pointer *op
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);
+ TestFree(desc->name);
+ TestFree(desc->filename);
+ xfree(desc);
}
return !failed;
}
--
If you want to reach me at my work email, use arjan at linux.intel.com
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
More information about the xorg
mailing list