Opened 20 years ago
Closed 19 years ago
#109 closed Bugs (Rejected)
counted_base::add_ref not overflow-safe
Reported by: | nobody | Owned by: | nobody |
---|---|---|---|
Milestone: | Component: | smart_ptr | |
Version: | None | Severity: | |
Keywords: | Cc: |
Description
Greetings, In order to track the number of shared_ptrs that refer to a certain object, the function counted_base::add_ref calls the overloaded operator ++() of the corresponding count_type member data. That in turn does increment a variable of built-in type (volatile long), but it does not check wether the result fits into the variable or not. A possible solution: a) in atomic_count::operator ++(): if(value_ != std::numeric_limits<volatile long>::max()) ...call atomic increment else throw ... some exception b) at least mention this somewhere in the documentation. Although this is certainly a situation unlikely to be ever appearing in practice, it might happen and can be the source for lots of trouble. best regards, Thomas Mang
Note:
See TracTickets
for help on using tickets.