Config: HAL: Don't leak options on failure to add device

This showed up in Xephyr in particular, which denies new device requests.
This commit is contained in:
Daniel Stone 2007-12-28 15:47:57 +02:00
parent f44fd3f9e4
commit 190a050624

View File

@ -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);