summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2007-12-28 15:47:57 +0200
committerDaniel Stone <daniel@fooishbar.org>2007-12-28 15:51:36 +0200
commit190a0506243b39cd8dfc0e12068e3a3f416330f1 (patch)
tree5148d1879182d5462f1f19401fc5564cfb149e87
parentf44fd3f9e41bf467360ace93ef5b532d8f61fb2c (diff)
Config: HAL: Don't leak options on failure to add device
This showed up in Xephyr in particular, which denies new device requests.
-rw-r--r--config/hal.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/config/hal.c b/config/hal.c
index af96fc2c8..4ab296159 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -92,6 +92,8 @@ add_option(InputOption **options, const char *key, const char *value)
for (; *options; options = &(*options)->next)
;
*options = xcalloc(sizeof(**options), 1);
+ if (!*options) /* Yeesh. */
+ return;
(*options)->key = xstrdup(key);
(*options)->value = xstrdup(value);
(*options)->next = NULL;
@@ -156,7 +158,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
char *path = NULL, *driver = NULL, *name = NULL, *xkb_rules = NULL;
char *xkb_model = NULL, *xkb_layout = NULL, *xkb_variant = NULL;
char *xkb_options = NULL, *config_info = NULL;
- InputOption *options = NULL;
+ InputOption *options = NULL, *tmpo = NULL;
DeviceIntPtr dev;
DBusError error;
int type = TYPE_NONE;
@@ -234,6 +236,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
if (NewInputDeviceRequest(options, &dev) != Success) {
DebugF("[config/hal] NewInputDeviceRequest failed\n");
+ dev = NULL;
goto unwind;
}
@@ -259,6 +262,12 @@ unwind:
xfree(xkb_options);
if (config_info)
xfree(config_info);
+ while (!dev && (tmpo = options)) {
+ options = tmpo->next;
+ xfree(tmpo->key);
+ xfree(tmpo->value);
+ xfree(tmpo);
+ }
out_error:
dbus_error_free(&error);