Skip to content

Commit

Permalink
Updated to work with clang-12 and tighther constexpr check for StrFor…
Browse files Browse the repository at this point in the history
…mat().
  • Loading branch information
blais committed Nov 28, 2021
1 parent 7453b38 commit 3f70380
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions beancount/cparser/builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void Builder::AddOptionBinary(const string& key, string&& value, const location&
string value_str = std::move(value);

// Translate legacy option names to proto equivalents.
static std::vector<std::pair<string, string>> translations = {
static std::vector<std::pair<const char*, const char*>> translations = {
{"name_assets", "account_types { assets: '%s' }"},
{"name_liabilities", "account_types { liabilities: '%s' }"},
{"name_income", "account_types { income: '%s' }"},
Expand All @@ -76,8 +76,12 @@ void Builder::AddOptionBinary(const string& key, string&& value, const location&
};
for (const auto& translation : translations) {
if (key == translation.first) {
value_str = absl::StrFormat(translation.second.c_str(), value_str);
return AddOptionUnary(value_str, loc);
char buffer[1024];
if (std::snprintf(buffer, 1024, translation.second, value_str.c_str()) >= 1024) {
AddError(StrFormat("String too large for options: '%s'", value_str), loc);
return;
}
return AddOptionUnary(buffer, loc);
}
}

Expand Down
6 changes: 3 additions & 3 deletions third_party/cppbase/setup.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def setup_absl():
# 2020-09-23
http_archive(
name = "com_google_absl",
url = "https://github.com/abseil/abseil-cpp/archive/20200923.2.tar.gz",
sha256 = "bf3f13b13a0095d926b25640e060f7e13881bd8a792705dd9e161f3c2b9aa976",
strip_prefix = "abseil-cpp-20200923.2",
url = "https://github.com/abseil/abseil-cpp/archive/refs/heads/lts_2021_11_02.tar.gz",
#sha256 = "",
strip_prefix = "abseil-cpp-lts_2021_11_02",
)


Expand Down

0 comments on commit 3f70380

Please sign in to comment.