Handle calloc failures

This commit is contained in:
cpq committed 2021-01-26 12:16:58 +00:00
1 parent 7200f079bf
commit 8e52075636
5 files changed
+38 -12

No files matched your search

+8 -4
View File
@@ -383,10 +383,14 @@ void mg_http_serve_file(struct mg_connection *c, struct mg_http_message *hm,
fclose(fp);
} else {
struct http_data *d = (struct http_data *) calloc(1, sizeof(*d));
d->fp = fp;
d->old_pfn_data = c->pfn_data;
c->pfn = static_cb;
c->pfn_data = d;
if (d == NULL) {
mg_error(c, "static HTTP OOM");
} else {
d->fp = fp;
d->old_pfn_data = c->pfn_data;
c->pfn = static_cb;
c->pfn_data = d;
}
}
}
}