From 1afdf99f9c00155b0c250e9a358de0184933b27c Mon Sep 17 00:00:00 2001 From: skvlad Date: Fri, 2 Sep 2016 13:22:26 -0700 Subject: [PATCH] EventLogParser: use std::vector to reduce stack usage ParsedRtcEventLog::ParseStream was using a stack-allocated 64kb array for a temporary buffer. This was causing problems in build environments with restrictions on stack size. This change replaces it with an std::vector. NOTRY=true Review-Url: https://codereview.webrtc.org/2297343003 Cr-Commit-Position: refs/heads/master@{#14055} --- webrtc/call/rtc_event_log_parser.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webrtc/call/rtc_event_log_parser.cc b/webrtc/call/rtc_event_log_parser.cc index 59906b01c8..a2f95d0a75 100644 --- a/webrtc/call/rtc_event_log_parser.cc +++ b/webrtc/call/rtc_event_log_parser.cc @@ -124,7 +124,7 @@ bool ParsedRtcEventLog::ParseString(const std::string& s) { bool ParsedRtcEventLog::ParseStream(std::istream& stream) { events_.clear(); const size_t kMaxEventSize = (1u << 16) - 1; - char tmp_buffer[kMaxEventSize]; + std::vector tmp_buffer(kMaxEventSize); uint64_t tag; uint64_t message_length; bool success; @@ -162,7 +162,7 @@ bool ParsedRtcEventLog::ParseStream(std::istream& stream) { } // Read the next protobuf event to a temporary char buffer. - stream.read(tmp_buffer, message_length); + stream.read(tmp_buffer.data(), message_length); if (stream.gcount() != static_cast(message_length)) { LOG(LS_WARNING) << "Failed to read protobuf message from file."; return false; @@ -170,7 +170,7 @@ bool ParsedRtcEventLog::ParseStream(std::istream& stream) { // Parse the protobuf event from the buffer. rtclog::Event event; - if (!event.ParseFromArray(tmp_buffer, message_length)) { + if (!event.ParseFromArray(tmp_buffer.data(), message_length)) { LOG(LS_WARNING) << "Failed to parse protobuf message."; return false; }