From 859ffb7a9824f48fb9a0c37887339f2ce68edb5e Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Wed, 14 Jun 2017 07:48:00 +0200 Subject: [PATCH] tests: chip: fix potential segfault The automatically cleaned up string is not initialized, but if asprintf() failed, its contents would be undefined which could lead to a segmentation fault. Signed-off-by: Bartosz Golaszewski --- tests/tests-chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests-chip.c b/tests/tests-chip.c index ef905ca..09fe82e 100644 --- a/tests/tests-chip.c +++ b/tests/tests-chip.c @@ -76,7 +76,7 @@ static void chip_open_lookup(void) TEST_CLEANUP(test_close_chip) struct gpiod_chip *chip_by_name = NULL; TEST_CLEANUP(test_close_chip) struct gpiod_chip *chip_by_path = NULL; TEST_CLEANUP(test_close_chip) struct gpiod_chip *chip_by_num = NULL; - TEST_CLEANUP(test_free_str) char *chip_num; + TEST_CLEANUP(test_free_str) char *chip_num = NULL; TEST_ASSERT(asprintf(&chip_num, "%u", test_chip_num(1)) > 0); -- 2.30.2