From 10f68191eca584d90a41155719eee5df9c740bee Mon Sep 17 00:00:00 2001 From: _N3m0 Date: Sat, 30 Dec 2023 22:09:59 +0100 Subject: [PATCH] check if malloc return \!null --- main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 70bcfd8..3937e3c 100644 --- a/main.c +++ b/main.c @@ -59,6 +59,12 @@ size_t save_chunk(char* buffer, size_t itemsize, size_t nitems, void* ignore){ } void getPage(void){ + pageChunk = malloc(sizeof(*pageChunk) * DEFAULT_PAGE_LEN); + if (pageChunk == NULL){ + perror("ERROR: Buy more ram.\n"); + exit(1); + } + CURL* curl = curl_easy_init(); if (curl == NULL){ perror("ERROR: curl init failed.\n"); @@ -83,10 +89,8 @@ void printPage(void){ } int main(int argc, char* argv[]){ - pageChunk = malloc(sizeof(*pageChunk) * DEFAULT_PAGE_LEN); getUserConfig(argc, argv); - getPage(); printPage();