From 717cd9fecd7f8a421a47595f495cbe94ac21b3cd Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Thu, 30 Sep 2010 06:02:30 +0000 Subject: [PATCH] Minor fixes for mifare-desfire-format. - Free default_key; - Really stop on error. --- examples/mifare-desfire-format.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/mifare-desfire-format.c b/examples/mifare-desfire-format.c index 7a9d51f..71d7a64 100644 --- a/examples/mifare-desfire-format.c +++ b/examples/mifare-desfire-format.c @@ -77,7 +77,7 @@ main(int argc, char *argv[]) if (!device_count) errx (EXIT_FAILURE, "No NFC device found."); - for (size_t d = 0; d < device_count; d++) { + for (size_t d = 0; (!error) && (d < device_count); d++) { device = nfc_connect (&(devices[d])); if (!device) { warnx ("nfc_connect() failed."); @@ -110,7 +110,6 @@ main(int argc, char *argv[]) if (format) { int res; - MifareDESFireKey default_key = mifare_desfire_des_key_new_with_version (null_key_data); res = mifare_desfire_connect (tags[i]); if (res < 0) { @@ -119,12 +118,14 @@ main(int argc, char *argv[]) break; } + MifareDESFireKey default_key = mifare_desfire_des_key_new_with_version (null_key_data); res = mifare_desfire_authenticate (tags[i], 0, default_key); if (res < 0) { warnx ("Can't authenticate on Mifare DESFire target."); error = EXIT_FAILURE; break; } + mifare_desfire_key_free (default_key); res = mifare_desfire_format_picc (tags[i]); if (res < 0) {