tests: fix a memory leak in exit path
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Sat, 6 Jul 2019 17:31:36 +0000 (19:31 +0200)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Sat, 6 Jul 2019 17:31:36 +0000 (19:31 +0200)
When exiting normally we free all allocated resources (mostly to keep
valgrind quiet). The toolpath string is not being freed and pops up in
valgrind's "still reachable" category of leaks. Free this memory too
in the atexit() cleanup callback.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
tests/gpiod-test.c

index 621d837b86d13f0bf84b7d98dc684dfc3cb96041..82e23ea11dc63a83f693edb024cf78f186ff6e42 100644 (file)
@@ -311,6 +311,8 @@ static void cleanup_func(void)
        msg("cleaning up");
 
        free(globals.pipebuf);
+       if (globals.toolpath)
+               free(globals.toolpath);
 
        gpio_mockup_unref(globals.mockup);
 }