Skip to content

Commit

Permalink
alloc: fix memcpy_s error check
Browse files Browse the repository at this point in the history
This will check return value from memcpy_s

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
  • Loading branch information
abonislawski committed Jul 10, 2024
1 parent e8127d5 commit 1050510
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,13 @@ void *rbrealloc_align(void *ptr, uint32_t flags, uint32_t caps, size_t bytes,

new_ptr = _balloc_unlocked(flags, caps, bytes, alignment);

if (new_ptr && ptr && !(flags & SOF_MEM_FLAG_NO_COPY))
memcpy_s(new_ptr, copy_bytes, ptr, copy_bytes);
if (new_ptr && ptr && !(flags & SOF_MEM_FLAG_NO_COPY)) {
if (memcpy_s(new_ptr, copy_bytes, ptr, copy_bytes)) {
_rfree_unlocked(new_ptr);
k_spin_unlock(&memmap->lock, key);
return NULL;
}
}

if (new_ptr)
_rfree_unlocked(ptr);
Expand Down

0 comments on commit 1050510

Please sign in to comment.