From 190a0506243b39cd8dfc0e12068e3a3f416330f1 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 28 Dec 2007 15:47:57 +0200 Subject: Config: HAL: Don't leak options on failure to add device This showed up in Xephyr in particular, which denies new device requests. --- config/hal.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'config') 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); -- cgit v1.2.3