Menu

#52 init methods shouldn't raise exceptions

version 0.11
open
General (30)
5
2006-02-09
2006-02-09
Will Mason
No

When init raises an exception, the alloc'ed memory
leaks. Check this out:

OLText* myText = [[OLText alloc] init];

If init raises an exception, myText will never get the
value returned by alloc assigned to it. Therefore, it
becomes impossible to free the memory.

Make sure that init methods cannot raise exceptions.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.