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 *sectors = mifare_application_find (mad, aid);
|
||||||
MifareClassicSectorNumber *s = sectors;
|
MifareClassicSectorNumber *s = sectors;
|
||||||
|
|
||||||
if (!sectors)
|
if (!sectors) {
|
||||||
return errno = EBADF, -1;
|
/* mifare_application_find may also fail if malloc() fails */
|
||||||
|
if (errno != ENOMEM) errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
while (*s && nbytes && (res >= 0)) {
|
while (*s && nbytes && (res >= 0)) {
|
||||||
MifareClassicBlockNumber first_block = mifare_classic_sector_first_block (*s);
|
MifareClassicBlockNumber first_block = mifare_classic_sector_first_block (*s);
|
||||||
|
|
Loading…
Add table
Reference in a new issue