[CDRIVER-152] When calling API mongo_get_primary if mongo->primary has not been initalized results on memory overrun (REOPENING) Created: 24/Jun/12 Updated: 19/Oct/16 Resolved: 28/Jul/12 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | TBD |
| Fix Version/s: | 0.6, 0.7 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Jose Sebastian Battig | Assignee: | Gary Murakami |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | driver | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Visual C++ |
||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Major Change | ||||||||
| Description |
|
primary pointer is allocated here: MONGO_EXPORT void mongo_replset_init( mongo *conn, const char *name ) { conn->replset = bson_malloc( sizeof( mongo_replset ) ); conn->primary = bson_malloc( sizeof( mongo_host_port ) ); As you can see, the structure is not initialized in any shape or form. I solved the problem adding the following code after the malloc of primary: /* JSB */ And changing the following function to be aware of NULL value on the first char of host array. MONGO_EXPORT const char* mongo_get_primary(mongo* conn) { |
| Comments |
| Comment by Gary Murakami [ 28/Jul/12 ] |
|
Fixed in |
| Comment by Jose Sebastian Battig [ 24/Jun/12 ] |
|
I have re-opened this issue because the problem is indeed not solved. |