Skip to content

Commit 3052410

Browse files
committed
opt(util.string): 修化util::string::Replace()函数,对入参进行合法进检查
1 parent c5c5ecd commit 3052410

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

modules/util/string.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ size_t HexStrToRawData(const std::string &hex_str, std::vector<uint8_t> &out, co
238238
void Replace(std::string &target_str, const std::string &pattern_str, const std::string &replace_str,
239239
std::string::size_type start, std::string::size_type count)
240240
{
241+
if (target_str.empty() || start > target_str.size())
242+
return;
243+
241244
if (count == 0)
242245
count = UINT32_MAX;
243246

0 commit comments

Comments
 (0)