mirror of
https://github.com/nfc-tools/mfoc.git
synced 2026-03-10 12:29:01 +00:00
Check if nfc_init() returns a valid context
This fixes a potential segfault when libnfc is not correctly initialized
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user