diff options
author | Tiago Vignatti <vignatti@c3sl.ufpr.br> | 2007-07-05 02:47:34 -0300 |
---|---|---|
committer | Tiago Vignatti <vignatti@c3sl.ufpr.br> | 2007-07-05 02:47:34 -0300 |
commit | 9131d560a0d42067cc4e726e445e060216c9acdc (patch) | |
tree | ed71d19d31235912b2d3ba649f0add1baf0ac995 | |
parent | 41b485d5507821e41c3281c3c565647ae7582101 (diff) |
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.
-rw-r--r-- | hw/kdrive/src/kinput.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index efbf260ff..e3c3abc7c 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -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; } } } |