Check if nfc_init() returns a valid context
This fixes a potential segfault when libnfc is not correctly initialized
This commit is contained in:
parent
222ba1838c
commit
e1a2b0225f
1 changed files with 4 additions and 0 deletions
|
@ -582,6 +582,10 @@ void mf_init(mfreader *r)
|
|||
{
|
||||
// Connect to the first NFC device
|
||||
nfc_init(&context);
|
||||
if (context == NULL) {
|
||||
ERR("Unable to init libnfc (malloc)");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
r->pdi = nfc_open(context, NULL);
|
||||
if (!r->pdi) {
|
||||
printf("No NFC device found.\n");
|
||||
|
|
Loading…
Reference in a new issue