[CXX-1511] Client constructor should throw if mongoc_uri_new_with_error fails Created: 05/Feb/18 Updated: 28/Oct/23 Resolved: 01/Mar/18 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 3.3.0-rc0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Matt Broadstone | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
It is possible for mongoc_uri_new_with_error to return NULL, and we are completely ignoring this fact during construction of mongocxx::client. It's very unlikely that this would happen, as most of the paths that would return an error would be covered during construction of the mongoc_uri_t passed in, but we should throw nonetheless in the unlikely case that this does happen. |
| Comments |
| Comment by Githook User [ 02/Mar/18 ] | ||||||
|
Author: {'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis'}Message: | ||||||
| Comment by Matt Broadstone [ 24/Feb/18 ] | ||||||
|
The constructor for client uses libmongoc::client_new_from_uri, which returns a mongoc_client_t *. I checked the implementation, and it's true that we do not, in fact, return NULL in any case - so if you are committed to making sure we never ever return NULL from that function then this is safe, otherwise we should check that the result is non-null and throw an exception. | ||||||
| Comment by A. Jesse Jiryu Davis [ 23/Feb/18 ] | ||||||
|
Don't think this is a bug. The driver's uri class is constructed like:
... and the client constructor takes a uri instance. What path leads us to construct a client with a NULL mongoc_uri_t pointer? |