Check malloc() return value.
Fixes issue 25.
This commit is contained in:
parent
0ad6a09cda
commit
3085408bf2
1 changed files with 3 additions and 1 deletions
|
@ -188,9 +188,11 @@ freefare_get_tag_friendly_name (MifareTag tag)
|
|||
char *
|
||||
freefare_get_tag_uid (MifareTag tag)
|
||||
{
|
||||
char *res = malloc (2 * tag->info.szUidLen + 1);
|
||||
char *res;
|
||||
if ((res = malloc (2 * tag->info.szUidLen + 1))) {
|
||||
for (size_t i =0; i < tag->info.szUidLen; i++)
|
||||
snprintf (res + 2*i, 3, "%02x", tag->info.abtUid[i]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue