Display right message when no tag is detected

This fixes a potential segfault due to an access to uninitialised memory variable access
This commit is contained in:
Romuald Conty 2013-12-06 15:22:42 +01:00
parent fa47ca0223
commit 222ba1838c

View file

@ -204,10 +204,13 @@ int main(int argc, char *const argv[])
for (i=0;!nfc_initiator_select_passive_target(r.pdi, nm, NULL, 0, &t.nt) && i < 10; i++) zsleep (100);
*/
// mf_select_tag(r.pdi, &(t.nt));
if (nfc_initiator_select_passive_target(r.pdi, nm, NULL, 0, &t.nt) < 0) {
int tag_count;
if ((tag_count = nfc_initiator_select_passive_target(r.pdi, nm, NULL, 0, &t.nt)) < 0) {
nfc_perror(r.pdi, "nfc_initiator_select_passive_target");
goto error;
} else if (tag_count == 0) {
ERR("No tag found.");
goto error;
}
// Test if a compatible MIFARE tag is used