- CloseProxmark now clears global state.
- CloseProxmark now checks for a non-null serial_port before calling uart_close, to avoid unintentional double-free'ing serial_port.
- main now calls CloseProxmark once.
void CloseProxmark(void) {
conn.run = false;
pthread_join(USB_communication_thread, NULL);
- uart_close(sp);
+
+ if (sp) {
+ uart_close(sp);
+ }
+
#ifdef __linux__
// Fix for linux, it seems that it is extremely slow to release the serial port file descriptor /dev/*
if (serial_port_name) {
unlink(serial_port_name);
}
#endif
+
+ // Clean up our state
+ sp = NULL;
+ serial_port_name = NULL;
}
}
write_history(".history");
-
- if (usb_present) {
- CloseProxmark();
- }
if (script_file) {
fclose(script_file);