Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a26346

Browse filesBrowse files
committed
Check for 2 more out-of-memory conditions
1 parent bf49c77 commit 9a26346
Copy full SHA for 9a26346

File tree

Expand file treeCollapse file tree

1 file changed

+12
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-1
lines changed

‎src/HTTPMultipartBodyParser.cpp

Copy file name to clipboardExpand all lines: src/HTTPMultipartBodyParser.cpp
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,22 @@ void HTTPMultipartBodyParser::fillBuffer(size_t maxLen) {
6666
if (peekBuffer == NULL) {
6767
// Nothing in the buffer. Allocate one of the wanted size
6868
peekBuffer = (char *)malloc(maxLen);
69+
if (peekBuffer == NULL) {
70+
HTTPS_LOGE("Multipart: out of memory");
71+
discardBody();
72+
return;
73+
}
6974
bufPtr = peekBuffer;
7075
peekBufferSize = 0;
7176
} else if (peekBufferSize < maxLen) {
7277
// Something in the buffer, but not enough
73-
peekBuffer = (char *)realloc(peekBuffer, maxLen);
78+
char *newPeekBuffer = (char *)realloc(peekBuffer, maxLen);
79+
if (newPeekBuffer == NULL) {
80+
HTTPS_LOGE("Multipart: out of memory");
81+
discardBody();
82+
return;
83+
}
84+
peekBuffer = newPeekBuffer;
7485
bufPtr = peekBuffer + peekBufferSize;
7586
} else {
7687
// We already have enough data in the buffer.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.