From 95f8cb0a3d4139563545651887e718d1bf141fbb Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Tue, 30 Jul 2019 13:49:49 +0200 Subject: [PATCH] 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 --- tests/gpiod-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) -- 2.30.2