[Exceptional C++ Style] Item 23: To new, Perchance to throw, Part 2: Pragmatic Issues in Memory Management

David Nash David.Nash at WallStreetSystems.com
Thu Jan 20 06:40:50 EST 2005



Adrian wrote:
 
> One possible cause of allocation failure is the manifestation 
> of a bug or
> runtime fault, e.g. trying to allocate memory for a string 
> from a random
> size value or as a consequence of external attack (i.e. 
> another kind of
> bug). Then all probably is lost (see below).


Herb mentioned this too, especially in the context of a communications
handing program,
where the size of memory to allocate might be determined externally.

Then handling the failure gracefully (which in this context might be
rejecting a network message) and continuing is perfectly acceptable.

Dave




More information about the Effective-cpp mailing list