compiler: stop iterator on error
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 21 Jan 2019 22:58:04 +0000 (22:58 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 21 Jan 2019 22:58:04 +0000 (22:58 +0000)
    If there is an error reading or parsing an archive header, the
    Archive_iterator code would return a dummy header but would not mark
    itself as done.  The effect is that an invalid archive leads to an
    endless loop reading and re-reading the same archive header.  Avoid
    that by setting the offset to the end of the file, which will cause
    the iterator to == archive_end.

    No test since it doesn't seem worth constructing an invalid archive.

    Reviewed-on: https://go-review.googlesource.com/c/158217

From-SVN: r268129

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

index 3c1d270cb5c93b9dc9e9a0223cbbd151b926a13e..c5b51b79a9566468ac1846b78bf3fd0b26af92c9 100644 (file)
@@ -1,4 +1,4 @@
-c76ba3014e42cc6adc3d43709bba28c5ad7a6ba2
+e7427654f3af83e1feea727a62a97172d7721403
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index a6d54037ce788c731893533c558320baf7b7538b..868def7cc7579244a658c3fdd9606455f98cf2aa 100644 (file)
@@ -780,6 +780,7 @@ Archive_iterator::read_next_header()
                                      &this->next_off_))
        {
          this->header_.off = filesize;
+         this->off_ = filesize;
          return;
        }
       this->header_.off = this->off_;