Adds a graceful error if there is no memory for request body inspection

Issue #1517
This commit is contained in:
Felipe Zimmerle 2017-07-31 10:41:20 -03:00
parent 9a41942ce1
commit b36c4260c1
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277

View File

@ -838,7 +838,12 @@ int Transaction::requestBodyFromFile(const char *path) {
}
request_body.seekg(0, std::ios::end);
str.reserve(request_body.tellg());
try {
str.reserve(request_body.tellg());
} catch (...) {
debug(3, "Failed to allocate memory to load request body.");
return false;
}
request_body.seekg(0, std::ios::beg);
str.assign((std::istreambuf_iterator<char>(request_body)),
std::istreambuf_iterator<char>());