diff options
Diffstat (limited to 'payloads/libpayload/libc')
-rw-r--r-- | payloads/libpayload/libc/lar.c | 4 | ||||
-rw-r--r-- | payloads/libpayload/libc/malloc.c | 2 | ||||
-rw-r--r-- | payloads/libpayload/libc/readline.c | 2 |
3 files changed, 8 insertions, 0 deletions
diff --git a/payloads/libpayload/libc/lar.c b/payloads/libpayload/libc/lar.c index 225b19001a..9ee09e2ec6 100644 --- a/payloads/libpayload/libc/lar.c +++ b/payloads/libpayload/libc/lar.c @@ -113,6 +113,10 @@ struct LAR *openlar(void *addr) * tear on the heap */ lar->headers = malloc(16 * sizeof(void *)); + + if (!lar->headers) + return NULL; + lar->alloc = 16; lar->count = lar->eof = 0; lar->cindex = 0; diff --git a/payloads/libpayload/libc/malloc.c b/payloads/libpayload/libc/malloc.c index d18b289adf..4cb71f6ff4 100644 --- a/payloads/libpayload/libc/malloc.c +++ b/payloads/libpayload/libc/malloc.c @@ -309,6 +309,8 @@ void *memalign(size_t align, size_t size) if (size == 0) return 0; if (align_regions == 0) { align_regions = malloc(sizeof(struct align_region_t)); + if (align_regions == NULL) + return NULL; memset(align_regions, 0, sizeof(struct align_region_t)); } struct align_region_t *reg = align_regions; diff --git a/payloads/libpayload/libc/readline.c b/payloads/libpayload/libc/readline.c index 01a565a698..9387e09149 100644 --- a/payloads/libpayload/libc/readline.c +++ b/payloads/libpayload/libc/readline.c @@ -55,6 +55,8 @@ char *readline(const char *prompt) if (!readline_buffer || !readline_bufferlen) { #define READLINE_BUFFERSIZE 256 readline_buffer = malloc(READLINE_BUFFERSIZE); + if (!readline_buffer) + return NULL; readline_bufferlen = READLINE_BUFFERSIZE; memset(readline_buffer, 0, readline_bufferlen); } |