fix mem leaks
This commit is contained in:
@@ -253,6 +253,7 @@ int CmdEMVGPO(const char *cmd) {
|
|||||||
|
|
||||||
// calc PDOL
|
// calc PDOL
|
||||||
struct tlv *pdol_data_tlv = NULL;
|
struct tlv *pdol_data_tlv = NULL;
|
||||||
|
struct tlvdb *tmp_ext = NULL;
|
||||||
struct tlv data_tlv = {
|
struct tlv data_tlv = {
|
||||||
.tag = 0x83,
|
.tag = 0x83,
|
||||||
.len = datalen,
|
.len = datalen,
|
||||||
@@ -266,7 +267,7 @@ int CmdEMVGPO(const char *cmd) {
|
|||||||
ParamLoadFromJson(tlvRoot);
|
ParamLoadFromJson(tlvRoot);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tlvdb *tmp_ext = tlvdb_external(0x9f38, datalen, data);
|
tmp_ext = tlvdb_external(0x9f38, datalen, data);
|
||||||
pdol_data_tlv = dol_process((const struct tlv *)tmp_ext, tlvRoot, 0x83);
|
pdol_data_tlv = dol_process((const struct tlv *)tmp_ext, tlvRoot, 0x83);
|
||||||
if (!pdol_data_tlv){
|
if (!pdol_data_tlv){
|
||||||
PrintAndLogEx(ERR, "Can't create PDOL TLV.");
|
PrintAndLogEx(ERR, "Can't create PDOL TLV.");
|
||||||
@@ -285,8 +286,8 @@ int CmdEMVGPO(const char *cmd) {
|
|||||||
unsigned char *pdol_data_tlv_data = tlv_encode(pdol_data_tlv, &pdol_data_tlv_data_len);
|
unsigned char *pdol_data_tlv_data = tlv_encode(pdol_data_tlv, &pdol_data_tlv_data_len);
|
||||||
if (!pdol_data_tlv_data) {
|
if (!pdol_data_tlv_data) {
|
||||||
PrintAndLogEx(ERR, "Can't create PDOL data.");
|
PrintAndLogEx(ERR, "Can't create PDOL data.");
|
||||||
|
tlvdb_free(tmp_ext);
|
||||||
tlvdb_free(tlvRoot);
|
tlvdb_free(tlvRoot);
|
||||||
free(pdol_data_tlv);
|
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len));
|
PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len));
|
||||||
@@ -299,7 +300,8 @@ int CmdEMVGPO(const char *cmd) {
|
|||||||
|
|
||||||
if (pdol_data_tlv != &data_tlv)
|
if (pdol_data_tlv != &data_tlv)
|
||||||
free(pdol_data_tlv);
|
free(pdol_data_tlv);
|
||||||
|
|
||||||
|
tlvdb_free(tmp_ext);
|
||||||
tlvdb_free(tlvRoot);
|
tlvdb_free(tlvRoot);
|
||||||
|
|
||||||
if (sw)
|
if (sw)
|
||||||
@@ -434,6 +436,7 @@ int CmdEMVAC(const char *cmd) {
|
|||||||
|
|
||||||
// calc CDOL
|
// calc CDOL
|
||||||
struct tlv *cdol_data_tlv = NULL;
|
struct tlv *cdol_data_tlv = NULL;
|
||||||
|
struct tlvdb *tmp_ext = NULL;
|
||||||
struct tlv data_tlv = {
|
struct tlv data_tlv = {
|
||||||
.tag = 0x01,
|
.tag = 0x01,
|
||||||
.len = datalen,
|
.len = datalen,
|
||||||
@@ -448,7 +451,7 @@ int CmdEMVAC(const char *cmd) {
|
|||||||
ParamLoadFromJson(tlvRoot);
|
ParamLoadFromJson(tlvRoot);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tlvdb *tmp_ext = tlvdb_external(0x8c, datalen, data);
|
tmp_ext = tlvdb_external(0x8c, datalen, data);
|
||||||
cdol_data_tlv = dol_process((const struct tlv *)tmp_ext, tlvRoot, 0x01); // 0x01 - dummy tag
|
cdol_data_tlv = dol_process((const struct tlv *)tmp_ext, tlvRoot, 0x01); // 0x01 - dummy tag
|
||||||
if (!cdol_data_tlv){
|
if (!cdol_data_tlv){
|
||||||
PrintAndLogEx(ERR, "Can't create CDOL TLV.");
|
PrintAndLogEx(ERR, "Can't create CDOL TLV.");
|
||||||
@@ -473,6 +476,8 @@ int CmdEMVAC(const char *cmd) {
|
|||||||
|
|
||||||
if (cdol_data_tlv != &data_tlv)
|
if (cdol_data_tlv != &data_tlv)
|
||||||
free(cdol_data_tlv);
|
free(cdol_data_tlv);
|
||||||
|
|
||||||
|
tlvdb_free(tmp_ext);
|
||||||
tlvdb_free(tlvRoot);
|
tlvdb_free(tlvRoot);
|
||||||
|
|
||||||
if (sw)
|
if (sw)
|
||||||
@@ -578,6 +583,7 @@ int CmdEMVInternalAuthenticate(const char *cmd) {
|
|||||||
|
|
||||||
// calc DDOL
|
// calc DDOL
|
||||||
struct tlv *ddol_data_tlv = NULL;
|
struct tlv *ddol_data_tlv = NULL;
|
||||||
|
struct tlvdb *tmp_ext = NULL;
|
||||||
struct tlv data_tlv = {
|
struct tlv data_tlv = {
|
||||||
.tag = 0x01,
|
.tag = 0x01,
|
||||||
.len = datalen,
|
.len = datalen,
|
||||||
@@ -592,7 +598,7 @@ int CmdEMVInternalAuthenticate(const char *cmd) {
|
|||||||
ParamLoadFromJson(tlvRoot);
|
ParamLoadFromJson(tlvRoot);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tlvdb *tmp_ext = tlvdb_external(0x9f49, datalen, data);
|
tmp_ext = tlvdb_external(0x9f49, datalen, data);
|
||||||
ddol_data_tlv = dol_process((const struct tlv *)tmp_ext, tlvRoot, 0x01); // 0x01 - dummy tag
|
ddol_data_tlv = dol_process((const struct tlv *)tmp_ext, tlvRoot, 0x01); // 0x01 - dummy tag
|
||||||
if (!ddol_data_tlv){
|
if (!ddol_data_tlv){
|
||||||
PrintAndLogEx(ERR, "Can't create DDOL TLV.");
|
PrintAndLogEx(ERR, "Can't create DDOL TLV.");
|
||||||
@@ -617,6 +623,8 @@ int CmdEMVInternalAuthenticate(const char *cmd) {
|
|||||||
|
|
||||||
if (ddol_data_tlv != &data_tlv)
|
if (ddol_data_tlv != &data_tlv)
|
||||||
free(ddol_data_tlv);
|
free(ddol_data_tlv);
|
||||||
|
|
||||||
|
tlvdb_free(tmp_ext);
|
||||||
tlvdb_free(tlvRoot);
|
tlvdb_free(tlvRoot);
|
||||||
|
|
||||||
if (sw)
|
if (sw)
|
||||||
|
|||||||
Reference in New Issue
Block a user