Joe Duffy has an
interesting article on
secure exception handling (which I will call
"why bar() is more secure than foo()". That is, of course, an oversimplification to avoid spoilers to the real article. :-)
void
foo()
{
// Impersonate
try
{
// something causes an exception...
}
finally
{
// revert impersonation
}
}
void
bar()
{
// Impersonate
try
{
// something causes an exception...
}
catch
{
// revert impersonation
throw;
}
finally
{
// revert impersonation
}
}