summaryrefslogtreecommitdiff
path: root/docs/examples/crawler.c
diff options
context:
space:
mode:
authorNils Gillmann <ng0@n0.is>2018-11-10 16:48:24 +0000
committerNils Gillmann <ng0@n0.is>2018-11-10 16:48:24 +0000
commit92533ade41f9b4860248c92bbcb3ee5d2bac0d66 (patch)
tree56919dee5ad5455a75045e7e0ead8eabc7bd5886 /docs/examples/crawler.c
parent544c3c6aed15d4198ccc1d38cfaee6329faadaf0 (diff)
parent196677150f711a96c38ed123e621f1d4e995b2e5 (diff)
downloadgnurl-92533ade41f9b4860248c92bbcb3ee5d2bac0d66.tar.gz
gnurl-92533ade41f9b4860248c92bbcb3ee5d2bac0d66.tar.bz2
gnurl-92533ade41f9b4860248c92bbcb3ee5d2bac0d66.zip
Merge tag 'curl-7_62_0'
7.62.0 Signed-off-by: Nils Gillmann <ng0@n0.is>
Diffstat (limited to 'docs/examples/crawler.c')
-rw-r--r--docs/examples/crawler.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/docs/examples/crawler.c b/docs/examples/crawler.c
index dd1d9f700..32e6050f8 100644
--- a/docs/examples/crawler.c
+++ b/docs/examples/crawler.c
@@ -52,7 +52,13 @@ size_t grow_buffer(void *contents, size_t sz, size_t nmemb, void *ctx)
{
size_t realsize = sz * nmemb;
memory *mem = (memory*) ctx;
- mem->buf = realloc(mem->buf, mem->size + realsize);
+ char *ptr = realloc(mem->buf, mem->size + realsize);
+ if(!ptr) {
+ /* out of memory */
+ printf("not enough memory (realloc returned NULL)\n");
+ return 0;
+ }
+ mem->buf = ptr;
memcpy(&(mem->buf[mem->size]), contents, realsize);
mem->size += realsize;
return realsize;