mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-19 11:09:42 +00:00
Handle calloc failures
This commit is contained in:
1 parent
7200f079bf
commit
8e52075636
5 files changed
+38
-12
No files matched your search
+8
-4
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user