Private
Public Access
2
0

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 <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2017-04-06 20:40:17 +02:00
parent f911e0620e
commit 6d004ca80d

View File

@@ -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();
}