diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c index 74936a5bd..b1fc83b14 100644 --- a/hw/xfree86/common/xf86Configure.c +++ b/hw/xfree86/common/xf86Configure.c @@ -181,7 +181,9 @@ configureInputSection(void) } } - mouse = calloc(1, sizeof(XF86ConfInputRec)); + if (!(mouse = calloc(1, sizeof(XF86ConfInputRec)))) + return NULL; + mouse->inp_identifier = XNFstrdup("Mouse0"); mouse->inp_driver = XNFstrdup("mouse"); mouse->inp_option_lst = @@ -213,9 +215,9 @@ configureScreenSection(int screennum) ptr->scrn_device_str = tmp; for (i = 0; i < ARRAY_SIZE(depths); i++) { - XF86ConfDisplayPtr conf_display; - - conf_display = calloc(1, sizeof(XF86ConfDisplayRec)); + XF86ConfDisplayPtr conf_display = calloc(1, sizeof(XF86ConfDisplayRec)); + if (!conf_display) + continue; conf_display->disp_depth = depths[i]; conf_display->disp_black.red = conf_display->disp_white.red = -1; conf_display->disp_black.green = conf_display->disp_white.green = -1; @@ -412,9 +414,9 @@ configureModuleSection(void) elist = LoaderListDir("extensions", NULL); if (elist) { for (el = elist; *el; el++) { - XF86LoadPtr module; - - module = calloc(1, sizeof(XF86LoadRec)); + XF86LoadPtr module = calloc(1, sizeof(XF86LoadRec)); + if (!module) + return ptr; module->load_name = *el; ptr->mod_load_lst = (XF86LoadPtr) xf86addListItem((glp) ptr-> mod_load_lst, diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c index b5b443242..d6cf97a59 100644 --- a/hw/xfree86/common/xf86Option.c +++ b/hw/xfree86/common/xf86Option.c @@ -844,13 +844,15 @@ xf86NameCmp(const char *s1, const char *s2) char * xf86NormalizeName(const char *s) { - char *ret, *q; + char *q; const char *p; if (s == NULL) return NULL; - ret = malloc(strlen(s) + 1); + char *ret = calloc(1, strlen(s) + 1); + if (!ret) + return NULL; for (p = s, q = ret; *p != 0; p++) { switch (*p) { case '_':