]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR go/90110
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Apr 2019 04:11:22 +0000 (04:11 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Apr 2019 04:11:22 +0000 (04:11 +0000)
    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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270434 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/import.cc

index 381d791da8c163c07a2916d13612dfe823cdc699..6007b4f750a800154112e90455843530f559e62b 100644 (file)
@@ -1,4 +1,4 @@
-20010e494f46d8fd58cfd372093b059578d3379a
+ecbd6562aff604b9559f63d714e922a0c9c2a77f
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index d783043ec04514e244a34537f2e2a23861129a97..c1982eb4300951dfbd9a3dcb10f8e5d5c2f76d5e 100644 (file)
@@ -1478,8 +1478,9 @@ Import_function_body::read_type()
   this->off_ = i + 1;
 
   char *end;
-  long val = strtol(this->body_.substr(start, i - start).c_str(), &end, 10);
-  if (*end != '\0' || i > 0x7fffffff)
+  std::string num = this->body_.substr(start, i - start);
+  long val = strtol(num.c_str(), &end, 10);
+  if (*end != '\0' || val > 0x7fffffff)
     {
       if (!this->saw_error_)
        go_error_at(this->location(),