View Revisions: Issue #3343

Summary 0003343: LicenseValidator constructor catches all exceptions, then rethrows
Revision 2019-06-15 10:44 by WA9PIE
Description I found this cdoe in the constructor for LicenseValidator (in LicenseValidator.cpp)

    catch (...)
    {
        throw;
    }


There's really no reason for this code to exist. If an exception is thrown, it should be handled by trapping a specific exception type. Catching all exception types with "..." is an anti-pattern. Worse, this code catches all exceptions, then simply re-throws them; there's no conceivable reason for this.

Further, if there is an exception, I think this code leaks because the try block includes at least one statement that allocates resources without a path to free them during exception handling.

Revision 2019-06-11 08:33 by K7ZCZ
Description
I found this cdoe in the constructor for LicenseValidator (in LicenseValidator.cpp)

    catch (...)
    {
        throw;
    }


There's really no reason for this code to exist. If an exception is thrown, it should be handled by trapping a specific exception type. Catching all exception types with "..." is an anti-pattern. Worse, this code catches all exceptions, then simply re-throws them; there's no conceivable reason for this.

Further, if there is an exception, I think this code leaks because the try block includes at least one statement that allocates resources without a path to free them during exception handling.