From 6b7099527ad70392cbe546e2a2ecb0b3ad83e9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Mon, 27 Jan 2025 13:49:51 +0100 Subject: [PATCH] VideoEncoder: rtc::StringBuilder instead of rtc::SimpleStringBuilder. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Whenever encoding info change, this ToString() method is called for some LS_INFO logging inside video_stream_encoder.cc. Apparently the char buffer used for constructing this string is not large enough because I can get WebRTC to crash in a demo page that gets and sets a lot of parameters. By changing to rtc::StringBuilder, we don't have to make assumptions about how long the string can get at runtime. Bug: None Change-Id: I32695523282143a301c0e13e06082d55bd2796b3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/375520 Commit-Queue: Henrik Boström Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#43805} --- api/video_codecs/video_encoder.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/api/video_codecs/video_encoder.cc b/api/video_codecs/video_encoder.cc index c5b851ae11..5fa7df65b6 100644 --- a/api/video_codecs/video_encoder.cc +++ b/api/video_codecs/video_encoder.cc @@ -120,9 +120,7 @@ VideoEncoder::EncoderInfo::EncoderInfo(const EncoderInfo&) = default; VideoEncoder::EncoderInfo::~EncoderInfo() = default; std::string VideoEncoder::EncoderInfo::ToString() const { - char string_buf[2048]; - rtc::SimpleStringBuilder oss(string_buf); - + rtc::StringBuilder oss; oss << "EncoderInfo { " "ScalingSettings { "; if (scaling_settings.thresholds) {