diff --git a/utils/nfc-mfclassic.c b/utils/nfc-mfclassic.c index 7fa16d7..244af45 100644 --- a/utils/nfc-mfclassic.c +++ b/utils/nfc-mfclassic.c @@ -822,9 +822,17 @@ main(int argc, const char *argv[]) } printf("Done.\n"); fclose(pfDump); + } else { + nfc_close(pnd); + nfc_exit(context); + exit(EXIT_FAILURE); } } else if (atAction == ACTION_WRITE) { - write_card(unlock); + if (!write_card(unlock)) { + nfc_close(pnd); + nfc_exit(context); + exit(EXIT_FAILURE); + } } nfc_close(pnd);