[kservice] add NULL check for rt_free and rt_free_align.

This commit is contained in:
朱天龙 (Armink) 2022-06-10 12:26:01 +08:00 committed by guo
parent 5ccf6a0fa8
commit 33be34d8ec
1 changed files with 4 additions and 0 deletions

View File

@ -1551,6 +1551,8 @@ RT_WEAK void rt_free(void *rmem)
/* call 'rt_free' hook */
RT_OBJECT_HOOK_CALL(rt_free_hook, (rmem));
/* NULL check */
if (rmem == RT_NULL) return;
/* Enter critical zone */
level = _heap_lock();
_MEM_FREE(rmem);
@ -1672,6 +1674,8 @@ RT_WEAK void rt_free_align(void *ptr)
{
void *real_ptr;
/* NULL check */
if (ptr == RT_NULL) return;
real_ptr = (void *) * (rt_ubase_t *)((rt_ubase_t)ptr - sizeof(void *));
rt_free(real_ptr);
}