From b9af7952a450b39d8bb042c19821a7d07b5027db Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 21 Jan 2019 15:28:33 +0100 Subject: [PATCH] demo: Fix crash when there are no supported devices Handle the empty list output from fp_discover_devs() when there are no supported devices. Closes: #146 --- demo/gtk-libfprint-test.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/demo/gtk-libfprint-test.c b/demo/gtk-libfprint-test.c index b23e38d..d0dd0c1 100644 --- a/demo/gtk-libfprint-test.c +++ b/demo/gtk-libfprint-test.c @@ -473,8 +473,17 @@ libfprint_demo_window_init (LibfprintDemoWindow *window) setup_pollfds (); discovered_devs = fp_discover_devs(); - if (!discovered_devs) + if (!discovered_devs) { + libfprint_demo_set_mode (window, ERROR_MODE); return; + } + + /* Empty list? */ + if (discovered_devs[0] == NULL) { + fp_dscv_devs_free (discovered_devs); + libfprint_demo_set_mode (window, EMPTY_MODE); + return; + } if (!fp_driver_supports_imaging(fp_dscv_dev_get_driver(discovered_devs[0]))) { libfprint_demo_set_mode (window, NOIMAGING_MODE);