Skip to content

Commit

Permalink
fix dangling pointer warning
Browse files Browse the repository at this point in the history
fixes:
external/jsonnet/cmd/jsonnet.cpp:298:31: warning: object backing the pointer will be destroyed at the end of the full-expression [-Wdangling-gsl]
            const char *arg = next_arg(i, args).c_str();
                              ^~~~~~~~~~~~~~~~~
  • Loading branch information
BenTheElder authored and sparkprime committed Oct 10, 2019
1 parent 552d8ec commit 0ea6884
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/jsonnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,15 @@ static ArgStatus process_args(int argc, const char **argv, JsonnetConfig *config
}
jsonnet_max_trace(vm, l);
} else if (arg == "--gc-growth-trigger") {
const char *arg = next_arg(i, args).c_str();
std::string num = next_arg(i, args);
char *ep;
double v = std::strtod(arg, &ep);
if (*ep != '\0' || *arg == '\0') {
std::cerr << "ERROR: invalid number \"" << arg << "\"" << std::endl;
double v = std::strtod(num.c_str(), &ep);
if (*ep != '\0' || num.length() == 0) {
std::cerr << "ERROR: invalid number \"" << num << "\"" << std::endl;
return ARG_FAILURE;
}
if (v < 0) {
std::cerr << "ERROR: invalid --gc-growth-trigger \"" << arg << "\""
std::cerr << "ERROR: invalid --gc-growth-trigger \"" << num << "\""
<< std::endl;
return ARG_FAILURE;
}
Expand Down

0 comments on commit 0ea6884

Please sign in to comment.