[SERVER-8861] GeoSearch::expandEndPoints can elicit --multiset::begin() Created: 05/Mar/13  Updated: 11/Jul/16  Resolved: 16/Mar/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.4.0-rc2
Fix Version/s: 2.5.0

Type: Bug Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 0
Labels: crash, geo
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

In GeoSearch::expandEndPoints there is an iterator decrement that can synthesize an iterator equivalent to --multiset::begin():

https://github.com/mongodb/mongo/blob/18de1d56412bfb89a6b3f95b18eeb770184fda15/src/mongo/db/geo/2d.cpp#L1823

This is illegal in C+11 even if the iterator is never dereferenced since one of the prerequisites for operator--() on a BidirectionalIterator 'r' is that there exists 's' such that r == ++s, and there is no such 's' for r == begin() [24.2.6]. This causes a crash when mongo is built against libc+.

Need to check C++98 to know for sure that this is illegal there (I'd guess it is), but it seems safer to not form the potentially illegal iterator anyway.



 Comments   
Comment by auto [ 16/Mar/13 ]

Author:

{u'date': u'2013-03-13T22:49:18Z', u'name': u'Andrew Morrow', u'email': u'acm@10gen.com'}

Message: SERVER-8861 Avoid forming iterator to before begin
Branch: master
https://github.com/mongodb/mongo/commit/a60108e953f2b20a6803466f2b622ae9f4b77ede

Generated at Thu Feb 08 03:18:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.