Skip to content

Commit 0fda478

Browse files
authored
Does not resize output for an empty response (#1175)
Adds additional checks to prevent crash and does not resize an output buffer in case of an empty HttpResponse with HttpStatusCode::OK Relates-To: OLPEDGE-2417 Signed-off-by: Iuliia Moroz <[email protected]>
1 parent d9198f3 commit 0fda478

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

olp-cpp-sdk-core/include/olp/core/client/HttpResponse.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ class CORE_API HttpResponse {
168168
*/
169169
void GetResponse(std::vector<unsigned char>& output) {
170170
response.seekg(0, std::ios::end);
171-
output.resize(response.tellg());
171+
const auto pos = response.tellg();
172+
if (pos > 0) {
173+
output.resize(pos);
174+
}
172175
response.seekg(0, std::ios::beg);
173176
response.read(reinterpret_cast<char*>(output.data()), output.size());
174177
response.seekg(0, std::ios::beg);

0 commit comments

Comments
 (0)