Skip to content

Commit f8924eb

Browse files
committed
alloc: fix memcpy_s error check
This will check return value from memcpy_s Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent cf450d2 commit f8924eb

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/lib/alloc.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,13 @@ void *rbrealloc_align(void *ptr, uint32_t flags, uint32_t caps, size_t bytes,
10191019

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

1022-
if (new_ptr && ptr && !(flags & SOF_MEM_FLAG_NO_COPY))
1023-
memcpy_s(new_ptr, copy_bytes, ptr, copy_bytes);
1022+
if (new_ptr && ptr && !(flags & SOF_MEM_FLAG_NO_COPY)) {
1023+
if (memcpy_s(new_ptr, copy_bytes, ptr, copy_bytes)) {
1024+
_rfree_unlocked(new_ptr);
1025+
k_spin_unlock(&memmap->lock, key);
1026+
return NULL;
1027+
}
1028+
}
10241029

10251030
if (new_ptr)
10261031
_rfree_unlocked(ptr);

0 commit comments

Comments
 (0)