Guarantee SSO is not applicable to fallback buffer

This commit is contained in:
Alex Hultman
2019-04-03 03:17:02 +02:00
parent 7f35d06920
commit d4bf6346df
2 changed files with 5 additions and 3 deletions
+5 -1
View File
@@ -29,6 +29,9 @@
namespace uWS {
/* We require at least this much post padding */
static const int MINIMUM_HTTP_POST_PADDING = 32;
class HttpRequest {
friend class HttpParser;
@@ -248,7 +251,8 @@ public:
int maxCopyDistance = std::min(MAX_FALLBACK_SIZE - fallback.length(), (size_t) length);
fallback.reserve(fallback.length() + maxCopyDistance + 32); // todo: padding should be same as libus
/* We don't want fallback to be short string optimized, since we want to move it */
fallback.reserve(fallback.length() + maxCopyDistance + std::max<int>(MINIMUM_HTTP_POST_PADDING, sizeof(std::string)));
fallback.append(data, maxCopyDistance);
// break here on break