net: lib: tls_credentials_shell: Fix crash during delete Deletion of credential should use the pointer from the reference slot not the temporary buffer, this causes a crash (unknown error). Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
diff --git a/subsys/net/lib/tls_credentials/tls_credentials_shell.c b/subsys/net/lib/tls_credentials/tls_credentials_shell.c index 7116de9..8ab9d4a 100644 --- a/subsys/net/lib/tls_credentials/tls_credentials_shell.c +++ b/subsys/net/lib/tls_credentials/tls_credentials_shell.c
@@ -564,8 +564,8 @@ ref_slot = cred->buf != NULL ? find_ref_slot(cred->buf) : -1; if (ref_slot >= 0) { /* This was a credential we copied to heap. Clear and free it. */ - memset((void *)cred_buf, 0, cred->len); - k_free((void *)cred_buf); + memset(&cred_refs[ref_slot], 0, cred->len); + k_free((void *)cred_refs[ref_slot]); cred->buf = NULL; /* Clear the reference slot so it can be used again. */