Bug #2528

Exception during Factory construction can lead to corrupt object

Added by J. Moringen almost 6 years ago. Updated almost 6 years ago.

Status:ResolvedStart date:04/12/2016
Priority:NormalDue date:
Assignee:J. Moringen% Done:

100%

Category:C++
Target version:rsb-0.14

Associated revisions

Revision a2b0dfa4
Added by J. Moringen almost 6 years ago

Reset factoryWhileLoadingPlugins in src/rsb/Factory.cpp

fixes #2528, refs #2487

The Factory constructor could be unwound by an exception thrown by the
plugin system, leaving factoryWhileLoadingPlugins pointing to a
half-initialized Factory object. To prevent this, reset
factoryWhileLoadingPlugins to NULL in case an exception is thrown by the
plugin system, then re-throw.

Unfortunately, I cannot come up with a reasonable test for this. The
error would be easy to trigger by doing

setenv("RSB_PLUGINS_CPP_LOAD", "foo", 1);
try { Factory f; } catch (...) {};
Factory f => segmentation fault

but that would require making the Factory constructor public or some
equally ugly friend hackery. sigh

  • src/rsb/Factory.cpp (header): updated copyright
    (Factory::Factory): reset factoryWhileLoadingPlugins in case an
    exception is thrown

History

#1 Updated by J. Moringen almost 6 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF