Skip to content

Commit db8171f

Browse files
OmerMorcopybara-github
authored andcommitted
Remove dependency on wcsnlen for string length calculation.
The `wcsnlen` function is not consistently available across all target environments. Its prior use was intended as a micro-optimization and safeguard to limit string scanning to the remaining buffer size and prevent potential issues with malformed strings lacking a null terminator. This change now relies on the implicit `std::wstring_view` constructor to determine the string length. `CopyToEncodedBuffer` will continue to handle truncation effectively, mitigating the original concerns. PiperOrigin-RevId: 756378282 Change-Id: I858bad01724507f7926f868aa300eabad8a4358c
1 parent 1b52dcb commit db8171f

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

absl/log/internal/log_message.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <algorithm>
2828
#include <array>
2929
#include <atomic>
30-
#include <cwchar>
3130
#include <ios>
3231
#include <memory>
3332
#include <ostream>
@@ -425,8 +424,7 @@ LogMessage& LogMessage::operator<< <const wchar_t*>(
425424
CopyToEncodedBuffer<StringType::kNotLiteral>(
426425
absl::string_view(kCharNull.data(), kCharNull.size() - 1));
427426
} else {
428-
CopyToEncodedBuffer<StringType::kNotLiteral>(
429-
std::wstring_view(v, wcsnlen(v, data_->encoded_remaining().size())));
427+
CopyToEncodedBuffer<StringType::kNotLiteral>(v);
430428
}
431429
return *this;
432430
}

0 commit comments

Comments
 (0)