From 9d1c3a3538f652200a0437fc40413a404146b7af Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 15 Sep 2018 12:00:53 +0200 Subject: [PATCH] FIX: crash on Bionic libc if CloseProxmark is called twice. (@micolous) https://github.com/Proxmark/proxmark3/pull/672 --- client/comms.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/client/comms.c b/client/comms.c index e0d0670ff..21d9ad4a7 100644 --- a/client/comms.c +++ b/client/comms.c @@ -141,7 +141,6 @@ static int getCommand(UsbCommand* response) { return 1; } - //----------------------------------------------------------------------------- // Entry point into our code: called whenever we received a packet over USB // that we weren't necessarily expecting, for example a debug print. @@ -339,9 +338,17 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode) void CloseProxmark(void) { conn.run = false; + + +#ifdef __BIONIC__ + if (USB_communication_thread != 0) { + pthread_join(USB_communication_thread, NULL); + } +#else pthread_join(USB_communication_thread, NULL); //pthread_join(FPC_communication_thread, NULL); - +#endif + if (sp) { uart_close(sp); } @@ -358,6 +365,7 @@ void CloseProxmark(void) { // Clean up our state sp = NULL; serial_port_name = NULL; + memset(&USB_communication_thread, 0, sizeof(pthread_t)); } /**