Collator::createInstance crashes in optimized code if makeInstance fails

Description

Collator::createInstance includes this code:

  • makeInstance either returns NULL with U_FAILURE(status), or non-NULL with U_SUCCESS(status).

  • setAttributesFromKeywords returns immediately if U_FAILURE(status), so in that case it does not actually use *coll.

  • however the fact that coll is dereferenced, even if not used, allows a C++ compiler to legally optimize the NULL check out of the implementation of delete.

  • so a makeInstance failure (e.g. from a bad collation keyword such as "ja@collation=private-kana") will cause such optimized code to crash.

One fix is just to add

before the setAttributesFromKeywords call.

Activity

Show:

Peter Edberg 
August 13, 2018 at 10:58 PM
(edited)

GitHub PR #54, reviewed by jefgen. Closing.

Fixed

Details

Assignee

Reporter

Components

Priority

Fix versions

Created August 7, 2018 at 10:38 PM
Updated October 24, 2018 at 5:54 PM
Resolved August 13, 2018 at 10:59 PM