Postpone options variable assignment to fix segfault when we got a device but

its driver is incorrect. Also if (!ki && !pi) can never be true.

This one also adds the device option field.
This commit is contained in:
Tiago Vignatti 2007-07-05 02:47:34 -03:00
parent 41b485d550
commit 9131d560a0

View File

@ -2317,13 +2317,11 @@ NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
pi = KdNewPointer();
if (!pi)
return BadAlloc;
pi->options = options;
}
else if (strcmp(option->value, "keyboard") == 0) {
ki = KdNewKeyboard();
if (!ki)
return BadAlloc;
ki->options = options;
}
else {
ErrorF("unrecognised device type!\n");
@ -2332,8 +2330,19 @@ NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
}
}
if (!ki && !pi) {
ErrorF("unrecognised device identifier!\n");
return BadValue;
}
for (option = options; option; option = option->next) {
if (strcmp(option->key, "driver") == 0) {
if (strcmp(option->key, "device") == 0) {
if (pi && option->value)
pi->path = KdSaveString(option->value);
else if (ki && option->value)
ki->path = KdSaveString(option->value);
}
else if (strcmp(option->key, "driver") == 0) {
if (pi) {
pi->driver = KdFindPointerDriver(option->value);
if (!pi->driver) {
@ -2341,6 +2350,7 @@ NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
KdFreePointer(pi);
return BadValue;
}
pi->options = options;
}
else if (ki) {
ki->driver = KdFindKeyboardDriver(option->value);
@ -2349,6 +2359,7 @@ NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
KdFreeKeyboard(ki);
return BadValue;
}
ki->options = options;
}
}
}