Skip to content
This repository was archived by the owner on Jun 19, 2022. It is now read-only.

Commit b9a8ea8

Browse files
committed
Fix memory struct
1 parent f882a5e commit b9a8ea8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

main.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ int main(int argc, char **argv) {
3737
}
3838

3939
struct memory chunk = {
40-
.memory = NULL,
40+
.memory = malloc(1),
4141
.size = 0
4242
};
43-
43+
if(!chunk.memory) {
44+
fprintf(stderr, "Not enough memory (malloc returned NULL)\n");
45+
return 1;
46+
}
47+
4448
snprintf(url, n, "https://boards.4channel.org/%s/catalog.json", board);
4549

4650
curl_easy_setopt(curl, CURLOPT_URL, url);
@@ -53,8 +57,7 @@ int main(int argc, char **argv) {
5357
fprintf(stderr, "curl_easy_perform() failed: %s\n",
5458
curl_easy_strerror(res));
5559
curl_easy_cleanup(curl);
56-
if(chunk.memory)
57-
free(chunk.memory);
60+
free(chunk.memory);
5861
free(url);
5962
return 1;
6063
}

0 commit comments

Comments
 (0)