Commit 5c727cf6 by Ian Lance Taylor

re PR go/90110 (libgo fails to build against glibc 2.19)

	PR go/90110
    compiler: use temporary to avoid early destruction
    
    The code was passing a substr directly to strtol, and then checking
    the *end value returned by strtol.  But the substr could be destroyed
    as soon as strtol returns, making the test of *end invalid.
    
    Also fix an incorrect test of the string index rather than the value.
    
    Fixes https://gcc.gnu.org/PR90110
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/172663

From-SVN: r270434
parent 5a58e967
20010e494f46d8fd58cfd372093b059578d3379a ecbd6562aff604b9559f63d714e922a0c9c2a77f
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -1478,8 +1478,9 @@ Import_function_body::read_type() ...@@ -1478,8 +1478,9 @@ Import_function_body::read_type()
this->off_ = i + 1; this->off_ = i + 1;
char *end; char *end;
long val = strtol(this->body_.substr(start, i - start).c_str(), &end, 10); std::string num = this->body_.substr(start, i - start);
if (*end != '\0' || i > 0x7fffffff) long val = strtol(num.c_str(), &end, 10);
if (*end != '\0' || val > 0x7fffffff)
{ {
if (!this->saw_error_) if (!this->saw_error_)
go_error_at(this->location(), go_error_at(this->location(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment