Commit 0713581d authored by Kishen Maloor's avatar Kishen Maloor

oc_cred: fix leak

Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent c9695683
Pipeline #608 failed with stage
in 4 minutes and 47 seconds
......@@ -389,7 +389,7 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client,
if (!subjectuuid) {
if (credusage != OC_CREDUSAGE_ROLE_CERT) {
return -1;
goto add_new_cred_error;
} else {
subject.id[0] = '*';
}
......@@ -439,6 +439,11 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client,
publicdata_size) == 0))
#endif /* OC_PKI */
) {
#ifdef OC_PKI
if (oc_string_len(public_key) > 0) {
oc_free_string(&public_key);
}
#endif /* OC_PKI */
return credid;
} else {
oc_sec_remove_cred_by_credid(credid, device);
......@@ -470,6 +475,9 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client,
publicdata_size == oc_string_len(cred->publicdata.data) &&
memcmp(publicdata, oc_string(cred->publicdata.data),
publicdata_size) == 0) {
if (oc_string_len(public_key) > 0) {
oc_free_string(&public_key);
}
return cred->credid;
}
}
......@@ -486,6 +494,9 @@ oc_sec_add_new_cred(size_t device, bool roles_resource, oc_tls_peer_t *client,
if ((oc_string_len(roles->publicdata.data) == publicdata_size) &&
memcmp(oc_string(roles->publicdata.data), publicdata,
publicdata_size) == 0) {
if (oc_string_len(public_key) > 0) {
oc_free_string(&public_key);
}
return roles->credid;
}
roles = roles->next;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment