diff --git a/interface/apdu/pcsc.c b/interface/apdu/pcsc.c index 47e795d..7ddc66d 100644 --- a/interface/apdu/pcsc.c +++ b/interface/apdu/pcsc.c @@ -379,8 +379,9 @@ static int pcsc_list_iter(int index, const char *reader, void *userdata) { cJSON *json = userdata; cJSON *jreader; + char index_str[16]; - char *index_str; + snprintf(index_str, sizeof(index_str), "%d", index); jreader = cJSON_CreateObject(); if (!jreader) @@ -388,21 +389,11 @@ static int pcsc_list_iter(int index, const char *reader, void *userdata) return -1; } - index_str = malloc(16); - if (!index_str) - { - return -1; - } - - snprintf(index_str, 16, "%d", index); - if (!cJSON_AddStringToObject(jreader, "env", index_str)) { return -1; } - free(index_str); - if (!cJSON_AddStringToObject(jreader, "name", reader)) { return -1;