From bf9d86e228d579f4237de9fef448007b25cd2460 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 23 Jul 2019 15:53:29 +1000 Subject: [PATCH] hidpp10: if the profile name is the empty string, make it NULL Because our profile struct can never have an NULL name, let's assume the empty string equals NULL. Signed-off-by: Peter Hutterer --- src/driver-hidpp10.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/driver-hidpp10.c b/src/driver-hidpp10.c index 043f7e5b..b11177c7 100644 --- a/src/driver-hidpp10.c +++ b/src/driver-hidpp10.c @@ -412,9 +412,12 @@ hidpp10drv_read_profile(struct ratbag_profile *profile) profile->is_enabled = p.enabled; - if (profile->name) + if (profile->name) { free(profile->name); - profile->name = strdup_safe((char*)p.name); + profile->name = NULL; + } + if (p.name && p.name[0] != '\0') + profile->name = strdup_safe((char*)p.name); rc = hidpp10_get_current_profile(hidpp10, &idx); if (rc == 0 && (unsigned int)idx == profile->index)