From 6d004ca80d370cf7d953377dcd6c53f9d72802a3 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Thu, 6 Apr 2017 20:40:17 +0200 Subject: [PATCH] mraa.c: mraa_deinit make plat pointer NULL after freeing it This fixes #698 where an application will crash after calling mraa_deinit and later closing calling deinit again because of the gcc destructor argument introduced with cac8f7a Signed-off-by: Brendan Le Foll --- src/mraa.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mraa.c b/src/mraa.c index 7863ede..51f2d63 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -247,6 +247,7 @@ mraa_deinit() if (plat->platform_type == MRAA_JSON_PLATFORM) { // Free the platform name free(plat->platform_name); + plat->platform_name = NULL; // Free the UART device path for (i = 0; i < plat->uart_dev_count; i++) { @@ -257,15 +258,21 @@ mraa_deinit() } #endif free(plat); + plat = NULL; - if (lang_func != NULL) + if (lang_func != NULL) { free(lang_func); + lang_func = NULL; + } - if (platform_name != NULL) + if (platform_name != NULL) { free(platform_name); + platform_name = NULL; + } } if (plat_iio != NULL) { free(plat_iio); + plat_iio = NULL; } closelog(); }