mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2025-12-25 00:10:05 +01:00
xfree86: duplicate xorg.conf device information before xf86NewInputDevice
xf86ConfigLayout.inputs contains the information from the xorg.conf
file. Passing this into xf86NewInputDevice means the device will get
cleaned up on exit and the pointers in xf86ConfigLayout.inputs are left
dangling. In the second server generation, this results in a server
crash.
Also, rename pDev to pInfo. pDev is pretty much reserved for DeviceIntPtr
types.
Reproducible: AutoAddDevices off and xorg.conf input sections, trigger
server regeneration.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
(cherry picked from commit f0d7e9db28)
This commit is contained in:
parent
e6336c3572
commit
f8f6783b9d
1 changed files with 27 additions and 5 deletions
|
|
@ -791,6 +791,21 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
|
|||
NULL);
|
||||
}
|
||||
|
||||
static InputInfoPtr
|
||||
duplicateDevice(InputInfoPtr pInfo)
|
||||
{
|
||||
InputInfoPtr dup = calloc(1, sizeof(InputInfoRec));
|
||||
if (dup) {
|
||||
dup->name = strdup(pInfo->name);
|
||||
dup->driver = strdup(pInfo->driver);
|
||||
dup->options = xf86OptionListDuplicate(pInfo->options);
|
||||
/* type_name is a const string */
|
||||
dup->type_name = pInfo->type_name;
|
||||
dup->fd = -1;
|
||||
}
|
||||
return dup;
|
||||
}
|
||||
|
||||
/*
|
||||
* InitInput --
|
||||
* Initialize all supported input devices.
|
||||
|
|
@ -799,7 +814,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
|
|||
void
|
||||
InitInput(int argc, char **argv)
|
||||
{
|
||||
InputInfoPtr* pDev;
|
||||
InputInfoPtr* pInfo;
|
||||
DeviceIntPtr dev;
|
||||
|
||||
xf86Info.vtRequestsPending = FALSE;
|
||||
|
|
@ -809,14 +824,21 @@ InitInput(int argc, char **argv)
|
|||
GetEventList(&xf86Events);
|
||||
|
||||
/* Initialize all configured input devices */
|
||||
for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
|
||||
for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) {
|
||||
InputInfoPtr dup;
|
||||
/* Replace obsolete keyboard driver with kbd */
|
||||
if (!xf86NameCmp((*pDev)->driver, "keyboard")) {
|
||||
strcpy((*pDev)->driver, "kbd");
|
||||
if (!xf86NameCmp((*pInfo)->driver, "keyboard")) {
|
||||
strcpy((*pInfo)->driver, "kbd");
|
||||
}
|
||||
|
||||
/* Data passed into xf86NewInputDevice will be freed on shutdown.
|
||||
* Duplicate from xf86ConfigLayout.inputs, otherwise we don't have any
|
||||
* xorg.conf input devices in the second generation
|
||||
*/
|
||||
dup = duplicateDevice(*pInfo);
|
||||
|
||||
/* If one fails, the others will too */
|
||||
if (xf86NewInputDevice(*pDev, &dev, TRUE) == BadAlloc)
|
||||
if (xf86NewInputDevice(dup, &dev, TRUE) == BadAlloc)
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue