tests: fix a potential segfault
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 12 Jun 2017 09:01:52 +0000 (11:01 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 12 Jun 2017 09:01:52 +0000 (11:01 +0200)
A string passed to test_free_str() must be allocated by malloc() or
NULL, so we need to initialize ptrn.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
tests/tests-gpioinfo.c

index e2b7419361aad13a658b826772d8c5b2fa790b6d..ff4a509e563dcc15c602d5a6abf06043532abc4e 100644 (file)
@@ -34,7 +34,7 @@ TEST_DEFINE(gpioinfo_simple,
 static void gpioinfo_one_exported(void)
 {
        TEST_CLEANUP(test_close_chip) struct gpiod_chip *chip = NULL;
-       TEST_CLEANUP(test_free_str) char *ptrn;
+       TEST_CLEANUP(test_free_str) char *ptrn = NULL;
        struct gpiod_line *line;
        int rv;