From 97bfc861657eae08bad06a1a7f807925b33ac669 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Fri, 4 Sep 2015 11:50:24 -0400 Subject: [PATCH] prevent a segfault in sanity_check_device If a device has missing profiles, profile will be null and we will have a segfault. Better say that the device failed the sanity check. Signed-off-by: Benjamin Tissoires --- src/libratbag.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libratbag.c b/src/libratbag.c index 471b2ab2..18a2035e 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -324,6 +324,9 @@ ratbag_sanity_check_device(struct ratbag_device *device) nprofiles = ratbag_device_get_num_profiles(device); for (i = 0; i < nprofiles; i++) { profile = ratbag_device_get_profile_by_index(device, i); + if (!profile) + goto out; + /* Allow max 1 default profile */ if (profile->is_default) { if (has_default) {