Skip to content

Bugfix: Don't use DECLARE_TYPE() with NULL dealloc

Fredrik Roubert requested to merge roubert/pyicu:dealloc into main

Using a NULL dealloc will result in calling the wrong destructor, the base class destructor (which isn't virtual) instead of the actual one.

In the ICU4C default configuration (U_OVERRIDE_CXX_ALLOCATION=1) this isn't immediately noticeable as the operator delete implementation there simply calls uprv_free() without caring about what is being deleted, but other implementations (U_OVERRIDE_CXX_ALLOCATION=0) aren't always as cavalier about this.

To resolve this, a new macro that declares a type appropriate dealloc is introduced and used to replace DECLARE_TYPE() with NULL dealloc for all ICU4C types with public destructors.

Tested using U_OVERRIDE_CXX_ALLOCATION=0 and TCMalloc.

Merge request reports

Loading