Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,8 +1042,10 @@ CK_RV C_CreateObject(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate,
return rv;
}
rv = AddObject(session, object, pTemplate, ulCount, phObject);
if (rv != CKR_OK)
if (rv != CKR_OK) {
WP11_Session_RemoveObject(session, object);
WP11_Object_Free(object);
}

WOLFPKCS11_LEAVE("C_CreateObject", rv);
return rv;
Expand Down
17 changes: 9 additions & 8 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1778,18 +1778,19 @@ static int wp11_storage_read_alloc_array(void* storage,

/* Read length of array. */
ret = wp11_storage_read_int(storage, len);
if (ret == 0) {
if (ret == 0 && *len > 0) {
/* Allocate buffer to hold data. */
*buffer = (unsigned char*)XMALLOC(*len, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (*buffer == NULL)
ret = MEMORY_E;
}
if (ret == 0) {
/* Read array data into allocated buffer. */
ret = wp11_storage_read(storage, *buffer, *len);
if (ret != 0) {
XFREE(*buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
*buffer = NULL;

if (ret == 0) {
/* Read array data into allocated buffer. */
ret = wp11_storage_read(storage, *buffer, *len);
if (ret != 0) {
XFREE(*buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
*buffer = NULL;
}
}
}

Expand Down
Loading