Skip to content

Commit

Permalink
Changed sprintf to snprintf (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxiMittel committed Feb 2, 2023
1 parent 78ffe17 commit e3e9e09
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ static std::string json_escape(std::string const& in)
// escape and print as unicode codepoint
constexpr int printed_unicode_length = 6; // 4 hex + letter 'u' + \0
std::array<char, printed_unicode_length> buf;
sprintf(buf.data(), "u%04x", ch);
snprintf(buf.data(), buf.size(), "u%04x", ch);
out.append(buf.data(), buf.size() - 1); // add only five, discarding the null terminator.
break;
}
Expand Down

0 comments on commit e3e9e09

Please sign in to comment.