Go patch committed: Use temporary to avoid early destruction

Ian Lance Taylor iant@golang.org
Thu Apr 18 06:26:00 GMT 2019


This patch to the Go frontend fixes a bug in which the code referred
to a temporary value after it was destroyed.  It also fixes an
incorrect test of the string index rather than the value parsed using
strtol.  This should fix PR 90110.  Bootstrapped and ran Go testsuite
on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
-------------- next part --------------
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 270373)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -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: gcc/go/gofrontend/import.cc
===================================================================
--- gcc/go/gofrontend/import.cc	(revision 270373)
+++ gcc/go/gofrontend/import.cc	(working copy)
@@ -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(),


More information about the Gcc-patches mailing list