XFree86: Fix memory leak in option parsing
Fix option parsing functions and callers thereof to not leak memory.
This commit is contained in:
parent
07c56abf84
commit
4771fa8747
|
@ -1271,7 +1271,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
|||
(count + 1) * sizeof(IDevRec));
|
||||
indp[count - 1] = Pointer;
|
||||
indp[count - 1].extraOptions =
|
||||
xf86addNewOption(NULL, "CorePointer", NULL);
|
||||
xf86addNewOption(NULL, xnfstrdup("CorePointer"), NULL);
|
||||
indp[count].identifier = NULL;
|
||||
servlayoutp->inputs = indp;
|
||||
}
|
||||
|
@ -1310,7 +1310,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
|||
(count + 1) * sizeof(IDevRec));
|
||||
indp[count - 1] = Pointer;
|
||||
indp[count - 1].extraOptions =
|
||||
xf86addNewOption(NULL, "AlwaysCore", NULL);
|
||||
xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL);
|
||||
indp[count].identifier = NULL;
|
||||
servlayoutp->inputs = indp;
|
||||
}
|
||||
|
@ -1401,7 +1401,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
|||
(count + 1) * sizeof(IDevRec));
|
||||
indp[count - 1] = Keyboard;
|
||||
indp[count - 1].extraOptions =
|
||||
xf86addNewOption(NULL, "CoreKeyboard", NULL);
|
||||
xf86addNewOption(NULL, xnfstrdup("CoreKeyboard"), NULL);
|
||||
indp[count].identifier = NULL;
|
||||
servlayoutp->inputs = indp;
|
||||
}
|
||||
|
|
|
@ -309,13 +309,16 @@ configureInputSection (void)
|
|||
mouse->inp_identifier = "Mouse0";
|
||||
mouse->inp_driver = "mouse";
|
||||
mouse->inp_option_lst =
|
||||
xf86addNewOption(mouse->inp_option_lst, "Protocol", DFLT_MOUSE_PROTO);
|
||||
xf86addNewOption(mouse->inp_option_lst, xstrdup("Protocol"),
|
||||
xstrdup(DFLT_MOUSE_PROTO));
|
||||
#ifndef __SCO__
|
||||
mouse->inp_option_lst =
|
||||
xf86addNewOption(mouse->inp_option_lst, "Device", DFLT_MOUSE_DEV);
|
||||
xf86addNewOption(mouse->inp_option_lst, xstrdup("Device"),
|
||||
xstrdup(DFLT_MOUSE_DEV));
|
||||
#endif
|
||||
mouse->inp_option_lst =
|
||||
xf86addNewOption(mouse->inp_option_lst, "ZAxisMapping", "4 5 6 7");
|
||||
xf86addNewOption(mouse->inp_option_lst, xstrdup("ZAxisMapping"),
|
||||
xstrdup("4 5 6 7"));
|
||||
ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
|
||||
return ptr;
|
||||
}
|
||||
|
@ -519,7 +522,7 @@ configureLayoutSection (void)
|
|||
iptr->iref_option_lst = NULL;
|
||||
iptr->iref_inputdev_str = "Mouse0";
|
||||
iptr->iref_option_lst =
|
||||
xf86addNewOption (iptr->iref_option_lst, "CorePointer", NULL);
|
||||
xf86addNewOption (iptr->iref_option_lst, xstrdup("CorePointer"), NULL);
|
||||
ptr->lay_input_lst = (XF86ConfInputrefPtr)
|
||||
xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
|
||||
}
|
||||
|
@ -532,7 +535,7 @@ configureLayoutSection (void)
|
|||
iptr->iref_option_lst = NULL;
|
||||
iptr->iref_inputdev_str = "Keyboard0";
|
||||
iptr->iref_option_lst =
|
||||
xf86addNewOption (iptr->iref_option_lst, "CoreKeyboard", NULL);
|
||||
xf86addNewOption (iptr->iref_option_lst, xstrdup("CoreKeyboard"), NULL);
|
||||
ptr->lay_input_lst = (XF86ConfInputrefPtr)
|
||||
xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
|
||||
}
|
||||
|
@ -751,7 +754,7 @@ configureDDCMonitorSection (int screennum)
|
|||
}
|
||||
|
||||
if (ConfiguredMonitor->features.dpms) {
|
||||
ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, "DPMS", NULL);
|
||||
ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, xstrdup("DPMS"), NULL);
|
||||
}
|
||||
|
||||
return ptr;
|
||||
|
|
|
@ -289,7 +289,7 @@ xf86CheckBoolOption(pointer optlist, const char *name, int deflt)
|
|||
_X_EXPORT pointer
|
||||
xf86ReplaceIntOption(pointer optlist, const char *name, const int val)
|
||||
{
|
||||
char *tmp = xnfalloc(16);
|
||||
char tmp[16];
|
||||
sprintf(tmp,"%i",val);
|
||||
return xf86AddNewOption(optlist,name,tmp);
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ xf86ReplaceIntOption(pointer optlist, const char *name, const int val)
|
|||
_X_EXPORT pointer
|
||||
xf86ReplaceRealOption(pointer optlist, const char *name, const double val)
|
||||
{
|
||||
char *tmp = xnfalloc(32);
|
||||
char tmp[32];
|
||||
snprintf(tmp,32,"%f",val);
|
||||
return xf86AddNewOption(optlist,name,tmp);
|
||||
}
|
||||
|
|
|
@ -198,21 +198,21 @@ addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
|
|||
{
|
||||
XF86OptionPtr new, old = NULL;
|
||||
|
||||
/* Don't allow duplicates */
|
||||
if (head != NULL && (old = xf86findOption(head, name)) != NULL)
|
||||
new = old;
|
||||
else {
|
||||
/* Don't allow duplicates, free old strings */
|
||||
if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
|
||||
new = old;
|
||||
xf86conffree(new->opt_name);
|
||||
xf86conffree(new->opt_val);
|
||||
}
|
||||
else
|
||||
new = xf86confcalloc (1, sizeof (XF86OptionRec));
|
||||
new->list.next = NULL;
|
||||
}
|
||||
new->opt_name = name;
|
||||
new->opt_val = val;
|
||||
new->opt_used = used;
|
||||
|
||||
if (old == NULL)
|
||||
return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
|
||||
else
|
||||
return head;
|
||||
new->opt_name = name;
|
||||
new->opt_val = val;
|
||||
new->opt_used = used;
|
||||
|
||||
if (old)
|
||||
return head;
|
||||
return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
|
||||
}
|
||||
|
||||
XF86OptionPtr
|
||||
|
|
|
@ -2111,7 +2111,7 @@ LayoutConfig(void)
|
|||
else
|
||||
iref->iref_option_lst =
|
||||
xf86addNewOption(iref->iref_option_lst,
|
||||
"CorePointer", NULL);
|
||||
XtNewString("CorePointer"), NULL);
|
||||
option = xf86findOption(mref->iref_option_lst,
|
||||
"CorePointer");
|
||||
XtFree(option->opt_name);
|
||||
|
@ -2209,7 +2209,7 @@ LayoutConfig(void)
|
|||
else
|
||||
iref->iref_option_lst =
|
||||
xf86addNewOption(iref->iref_option_lst,
|
||||
"CoreKeyboard", NULL);
|
||||
XtNewString("CoreKeyboard"), NULL);
|
||||
option = xf86findOption(kref->iref_option_lst,
|
||||
"CoreKeyboard");
|
||||
XtFree(option->opt_name);
|
||||
|
|
Loading…
Reference in New Issue
Block a user