3 ms·
In your example, storing a pointer to an item in the hashtable in a context that potentially outlives the hashtable items could qualify as "bad memory managemen
by jstimpfle 5y ago
In your example, storing a pointer to an item in the hashtable in a context that potentially outlives the hashtable items could qualify as "bad memory management". Long-lived cross-context pointers in general I frown upon (most pointers I use have their lifetime bound to a function call), although there are no hard rules of course, and you have a point in that these errors are not detected by most type systems or probably even static analyzers. Well, it's still a smell, because we know these types of problems and we know many ways to avoid most of them. I'm saying this all to support the claim that memory management needn't be hard, not to claim that there aren't any exploitable memory bugs out there, which would be an insane claim.