boot: add assertions
To silence coverity. Closes CID#1620098.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
08d8224c0a
commit
eb654a769d
+9
-3
@@ -46,10 +46,16 @@ static inline void *xmalloc_multiply(size_t n, size_t size) {
|
||||
/* Use malloc attribute as this never returns p like userspace realloc. */
|
||||
_malloc_ _alloc_(3) _returns_nonnull_ _warn_unused_result_
|
||||
static inline void *xrealloc(void *p, size_t old_size, size_t new_size) {
|
||||
assert(p || old_size == 0);
|
||||
|
||||
void *t = xmalloc(new_size);
|
||||
new_size = MIN(old_size, new_size);
|
||||
if (new_size > 0)
|
||||
memcpy(t, p, new_size);
|
||||
|
||||
size_t size = MIN(old_size, new_size);
|
||||
if (size > 0) {
|
||||
assert(p);
|
||||
memcpy(t, p, size);
|
||||
}
|
||||
|
||||
free(p);
|
||||
return t;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user