[geos-commits] [SCM] GEOS branch 3.8 updated. 93be2e1d5a143d757e6cf5fc7c29c7ef48919ccf

git at osgeo.org git at osgeo.org
Mon Nov 4 06:29:17 PST 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, 3.8 has been updated
       via  93be2e1d5a143d757e6cf5fc7c29c7ef48919ccf (commit)
      from  8dcb1e2b1c031a7523ac50c531cbb5e49786ef2d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 93be2e1d5a143d757e6cf5fc7c29c7ef48919ccf
Author: Daniel Baston <dbaston at gmail.com>
Date:   Wed Oct 23 21:07:23 2019 -0400

    Avoid access past end of vector
    
    In most configurations this access would be optimized out (as it is
    never used) but this is not always the case.
    
    Fixes #1002

diff --git a/NEWS b/NEWS
index 770c9b0..003c2f5 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Changes in 3.8.1
 
 - Bug fixes / improvements
   - Stack allocate line segments in OverlapUnion (Paul Ramsey)
+  - Avoid assertion failure with MSVC 2017 / 2019 (#1002, Dan Baston)
 
 
 Changes in 3.8.0
diff --git a/src/index/chain/MonotoneChainBuilder.cpp b/src/index/chain/MonotoneChainBuilder.cpp
index be5836a..242a923 100644
--- a/src/index/chain/MonotoneChainBuilder.cpp
+++ b/src/index/chain/MonotoneChainBuilder.cpp
@@ -96,29 +96,28 @@ MonotoneChainBuilder::findChainEnd(const CoordinateSequence& pts, std::size_t st
     // (which is the starting quadrant)
     int chainQuad = Quadrant::quadrant(pts[safeStart],
                                        pts[safeStart + 1]);
-    std::size_t last = start + 1;
 
-    const Coordinate* prev = &pts[last-1]; // avoid repeated coordinate access by index (virtual call)
-    const Coordinate* curr = &pts[last];
+    const Coordinate* prev; // avoid repeated coordinate access by index (virtual call)
+    const Coordinate* curr = &pts[start];
+
+    for(size_t last = start + 1; last < npts; last++) {
+        prev = curr;
+        curr = &pts[last];
 
-    while(last < npts) {
         // skip zero-length segments, but include them in the chain
         if(!prev->equals2D(*curr)) {
             // compute quadrant for next possible segment in chain
             int quad = Quadrant::quadrant(*prev, *curr);
             if(quad != chainQuad) {
-                break;
+                return last - 1;
             }
         }
-        ++last;
-        prev = curr;
-        curr = &pts[last];
     }
 #if GEOS_DEBUG
     std::cerr << "MonotoneChainBuilder::findChainEnd() returning" << std::endl;
 #endif
 
-    return last - 1;
+    return npts - 1;
 }
 
 } // namespace geos.index.chain

-----------------------------------------------------------------------

Summary of changes:
 NEWS                                     |  1 +
 src/index/chain/MonotoneChainBuilder.cpp | 17 ++++++++---------
 2 files changed, 9 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list