Skip to content

Commit

Permalink
Merge branch 'tarantool:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
nshy authored Jun 17, 2024
2 parents 80a29be + 3d97334 commit c709622
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions asan/lsan.supp
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ leak:box_tuple_update
leak:box_tuple_iterator
leak:box_index_iterator_after
leak:ibuf_reserve_slow
leak:box_check_slice
21 changes: 14 additions & 7 deletions test/fuzz/luaL_loadbuffer/serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ ClearIdentifier(const std::string &identifier)
} else if (std::isalpha(c) || c == '_') {
has_first_not_digit = true;
cleared += c;
} else {
cleared += '_';
}
}
return cleared;
Expand All @@ -456,12 +458,13 @@ clamp(double number, double upper, double lower)
}

inline std::string
ConvertToStringDefault(const std::string &s)
ConvertToStringDefault(const std::string &s, bool sanitize = false)
{
std::string ident = ClearIdentifier(s);
ident = clamp(ident);
std::string ident = clamp(s);
if (sanitize)
ident = ClearIdentifier(ident);
if (ident.empty())
return std::string(kDefaultIdent);
ident = std::string(kDefaultIdent);
return ident;
}

Expand Down Expand Up @@ -951,7 +954,7 @@ NESTED_PROTO_TOSTRING(IndexWithName, indexname, Variable)
{
std::string indexname_str = PrefixExpressionToString(
indexname.prefixexp());
std::string idx_str = ConvertToStringDefault(indexname.name());
std::string idx_str = ConvertToStringDefault(indexname.name(), true);
/* Prevent using reserved keywords as indices. */
if (KReservedLuaKeywords.find(idx_str) != KReservedLuaKeywords.end()) {
idx_str += "_1";
Expand Down Expand Up @@ -1196,8 +1199,12 @@ PROTO_TOSTRING(UnaryOperator, op)
*/
PROTO_TOSTRING(Name, name)
{
std::string ident = ConvertToStringDefault(name.name());
return ident + std::to_string(name.num() % kMaxIdentifiers);
std::string ident = ConvertToStringDefault(name.name(), true);
/* Identifier has default name, add an index. */
if (!ident.compare(kDefaultIdent)) {
ident += std::to_string(name.num() % kMaxIdentifiers);
}
return ident;
}

} /* namespace */
Expand Down

0 comments on commit c709622

Please sign in to comment.