boostorg / locale

Boost.Locale
Boost Software License 1.0
32 stars 70 forks source link

Undefined behaviour when getting address in do_basic_transform #52

Closed OznOg closed 2 years ago

OznOg commented 4 years ago

in do_basic_transform https://github.com/boostorg/locale/blob/develop/src/icu/collator.cpp#L90 line int len = collate->getSortKey(str,&tmp[0],tmp.size());

seems wrong as there is no way to make sure tmp is not a 0 sized vector which leads &tmp[0] to be undefined behaviour. Moreover, on my fedora 30, a vector assertion fails __builtin_expect(__n < this->size(), true) and leads the program to crash.

A fix could be to use tmp.data() instead (if this function is really supposed to handle 0 lenght entry).

OznOg commented 3 years ago

a patch is proposed in https://github.com/boostorg/locale/pull/60

OznOg commented 2 years ago

was fixed in https://github.com/boostorg/locale/pull/72