xfree86: common: extra safety checks for NULL pointers
Even though it's unlikely ever getting it, still safer to have some extra checks / asserts than unexpected segfault. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
aad59c6dee
commit
c0d068229b
|
@ -341,9 +341,8 @@ configureLayoutSection(void)
|
||||||
ptr->lay_identifier = "X.org Configured";
|
ptr->lay_identifier = "X.org Configured";
|
||||||
|
|
||||||
{
|
{
|
||||||
XF86ConfInputrefPtr iptr;
|
XF86ConfInputrefPtr iptr = calloc(1, sizeof(XF86ConfInputrefRec));
|
||||||
|
assert(iptr);
|
||||||
iptr = malloc(sizeof(XF86ConfInputrefRec));
|
|
||||||
iptr->list.next = NULL;
|
iptr->list.next = NULL;
|
||||||
iptr->iref_option_lst = NULL;
|
iptr->iref_option_lst = NULL;
|
||||||
iptr->iref_inputdev_str = XNFstrdup("Mouse0");
|
iptr->iref_inputdev_str = XNFstrdup("Mouse0");
|
||||||
|
@ -355,9 +354,8 @@ configureLayoutSection(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
XF86ConfInputrefPtr iptr;
|
XF86ConfInputrefPtr iptr = calloc(1, sizeof(XF86ConfInputrefRec));
|
||||||
|
assert(iptr);
|
||||||
iptr = malloc(sizeof(XF86ConfInputrefRec));
|
|
||||||
iptr->list.next = NULL;
|
iptr->list.next = NULL;
|
||||||
iptr->iref_option_lst = NULL;
|
iptr->iref_option_lst = NULL;
|
||||||
iptr->iref_inputdev_str = XNFstrdup("Keyboard0");
|
iptr->iref_inputdev_str = XNFstrdup("Keyboard0");
|
||||||
|
@ -369,10 +367,10 @@ configureLayoutSection(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
|
for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
|
||||||
XF86ConfAdjacencyPtr aptr;
|
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
aptr = malloc(sizeof(XF86ConfAdjacencyRec));
|
XF86ConfAdjacencyPtr aptr = calloc(1, sizeof(XF86ConfAdjacencyRec));
|
||||||
|
assert(aptr);
|
||||||
aptr->list.next = NULL;
|
aptr->list.next = NULL;
|
||||||
aptr->adj_x = 0;
|
aptr->adj_x = 0;
|
||||||
aptr->adj_y = 0;
|
aptr->adj_y = 0;
|
||||||
|
@ -466,6 +464,7 @@ handle_detailed_input(struct detailed_monitor_section *det_mon, void *data)
|
||||||
ptr->mon_modelname = realloc(ptr->mon_modelname,
|
ptr->mon_modelname = realloc(ptr->mon_modelname,
|
||||||
strlen((char *) (det_mon->section.name)) +
|
strlen((char *) (det_mon->section.name)) +
|
||||||
1);
|
1);
|
||||||
|
assert(ptr->mon_modelname);
|
||||||
strcpy(ptr->mon_modelname, (char *) (det_mon->section.name));
|
strcpy(ptr->mon_modelname, (char *) (det_mon->section.name));
|
||||||
break;
|
break;
|
||||||
case DS_RANGES:
|
case DS_RANGES:
|
||||||
|
@ -655,6 +654,7 @@ DoConfigure(void)
|
||||||
XF86ConfMonitorPtr monitor_ptr;
|
XF86ConfMonitorPtr monitor_ptr;
|
||||||
XF86ConfScreenPtr screen_ptr;
|
XF86ConfScreenPtr screen_ptr;
|
||||||
|
|
||||||
|
assert(xf86config);
|
||||||
device_ptr = configureDeviceSection(screennum);
|
device_ptr = configureDeviceSection(screennum);
|
||||||
xf86config->conf_device_lst = (XF86ConfDevicePtr) xf86addListItem((glp)
|
xf86config->conf_device_lst = (XF86ConfDevicePtr) xf86addListItem((glp)
|
||||||
xf86config->
|
xf86config->
|
||||||
|
|
|
@ -616,7 +616,7 @@ removeInputHandler(IHPtr ih)
|
||||||
p = InputHandlers;
|
p = InputHandlers;
|
||||||
while (p && p->next != ih)
|
while (p && p->next != ih)
|
||||||
p = p->next;
|
p = p->next;
|
||||||
if (ih)
|
if (ih && p)
|
||||||
p->next = ih->next;
|
p->next = ih->next;
|
||||||
}
|
}
|
||||||
free(ih);
|
free(ih);
|
||||||
|
|
Loading…
Reference in New Issue