From: Bartosz Golaszewski Date: Wed, 14 Jun 2017 05:48:00 +0000 (+0200) Subject: tests: chip: fix potential segfault X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=859ffb7a9824f48fb9a0c37887339f2ce68edb5e;p=qemu-gpiodev%2Flibgpiod.git 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 --- 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);