Github user hcorg commented on a diff in the pull request:
https://github.com/apache/thrift/pull/1128#discussion_r88791621
--- Diff: compiler/cpp/src/thrift/generate/t_erl_generator.cc ---
@@ -968,10 +969,13 @@ void t_erl_generator::export_string(string name, int
num) {
}
void t_erl_generator::export_types_function(t_function* tfunction, string
prefix) {
-
+ t_struct::members_type::size_type num =
tfunction->get_arglist()->get_members().size();
+ if (num > std::numeric_limits<int>().max()) {
+ throw "integer overflow in t_erl_generator::export_types_function,
name " + tfunction->get_name();
--- End diff --
throwing std::string is an antipattern - it should at least be wrapped in
std::runtime_error
this code is also repeated in couple of places, maybe some utility function
could simplify it?
something like:
`template <typename To, typename From> To safe_numeric_cast(From i) { ... }`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---