mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-01 12:26:38 -05:00
Allocate minimum 1 byte in malloc_nofail when size is 0 to prevent process abort
This commit is contained in:
parent
527560d9a8
commit
1fa1cd7eec
1 changed files with 2 additions and 2 deletions
|
|
@ -2185,7 +2185,7 @@ void malloc_fail(size_t size)
|
||||||
|
|
||||||
void* malloc_nofail(size_t size)
|
void* malloc_nofail(size_t size)
|
||||||
{
|
{
|
||||||
void* ptr = malloc(size);
|
void* ptr = malloc(size ? size : 1);
|
||||||
|
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
/* LCOV_EXCL_START */
|
/* LCOV_EXCL_START */
|
||||||
|
|
@ -2218,7 +2218,7 @@ void* calloc_nofail(size_t count, size_t size)
|
||||||
size *= count;
|
size *= count;
|
||||||
|
|
||||||
/* see the note in malloc_nofail() of why we don't use calloc() */
|
/* see the note in malloc_nofail() of why we don't use calloc() */
|
||||||
ptr = malloc(size);
|
ptr = malloc(size ? size : 1);
|
||||||
|
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
/* LCOV_EXCL_START */
|
/* LCOV_EXCL_START */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue