Tell apart malloc failure from no application in mifare_application_write()
This commit is contained in:
parent
3e53c7811a
commit
0ad6a09cda
1 changed files with 5 additions and 2 deletions
|
@ -265,8 +265,11 @@ mifare_application_write (MifareTag tag, Mad mad, const MadAid aid, const void *
|
|||
MifareClassicSectorNumber *sectors = mifare_application_find (mad, aid);
|
||||
MifareClassicSectorNumber *s = sectors;
|
||||
|
||||
if (!sectors)
|
||||
return errno = EBADF, -1;
|
||||
if (!sectors) {
|
||||
/* mifare_application_find may also fail if malloc() fails */
|
||||
if (errno != ENOMEM) errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (*s && nbytes && (res >= 0)) {
|
||||
MifareClassicBlockNumber first_block = mifare_classic_sector_first_block (*s);
|
||||
|
|
Loading…
Reference in a new issue