Use of "throw 0" as flow-control

Bug #1106581 reported by Paul J. Lucas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
New
Medium
Nicolae Brinza

Bug Description

In loader_dtd.cpp for the loadXml() function, "throw 0" is used as "flow control" for the function. This is not an appropriate use of C++ exceptions. The very real danger is that the corresponding "catch (...)" swallows all other exceptions silently. This causes very hard-to-find bugs (as I recently had the misfortune of debugging).

The rule should be that if you ever write "catch (...)," the end of the catch block should ALWAYS rethrow the exception via "throw;". The catch block in this way only does some clean-up but makes no attempt to swallow the exception.

Please don't use "throw 0" with "catch (...)". Even using "goto" is better since it won't silently swallow exceptions.

Note that I have already cleaned up several other uses of "catch (...)" in the code (see bug #1103819). This bug is a related bug in that it's about the (mis)use of "catch (...)" but specifically a case I don't feel comfortable fixing myself. There is already a branch for all "catch (...)" fixes -- please use the bug-1103819 branch.

Related branches

Changed in zorba:
milestone: 2.9 → 3.0
Chris Hillery (ceejatec)
Changed in zorba:
milestone: 3.0 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.