From: Bartosz Golaszewski Date: Tue, 30 Jul 2019 11:49:49 +0000 (+0200) Subject: tests: fix a segfault in error path X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=95f8cb0a3d4139563545651887e718d1bf141fbb;p=qemu-gpiodev%2Flibgpiod.git tests: fix a segfault in error path We may all the atexit() cleanup func before the gpio_mockup context is setup. This will result in a segfault so add an appropriate check. Fixes: b8659e044d50 ("tests: use libgpiomockup") Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/gpiod-test.c b/tests/gpiod-test.c index 82e23ea..f75173c 100644 --- a/tests/gpiod-test.c +++ b/tests/gpiod-test.c @@ -314,7 +314,8 @@ static void cleanup_func(void) if (globals.toolpath) free(globals.toolpath); - gpio_mockup_unref(globals.mockup); + if (globals.mockup) + gpio_mockup_unref(globals.mockup); } static void event_lock(void)