8000 Prevents exception when parsing HTTP POST message without a body · olehs/esp32-snippets@472d151 · GitHub
[go: up one dir, main page]

Skip to content

Commit 472d151

Browse files
committed
Prevents exception when parsing HTTP POST message without a body
1 parent d38b15e commit 472d151

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cpp_utils/HttpParser.cpp

Lines changed: 3 additions & 1 deletion
< 456F td data-grid-cell-id="diff-d4974fbb58afffc85cefc6eb6c4fb5ddb750084583513a58a4538c63a3c672ee-224-226-1" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">226
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ void HttpParser::parse(Socket s) {
220220
} else {
221221
uint8_t data[512];
222222
int rc = s.receive(data, sizeof(data));
223-
m_body = std::string((char *)data, rc);
223+
if (rc > 0) {
224+
m_body = std::string((char *)data, rc);
225+
}
224
}
225227
ESP_LOGD(LOG_TAG, "<< parse: Size of body: %d", m_body.length());
226228
} // parse

0 commit comments

Comments
 (0)
0