PIM: fix libphonenumer patch

The "Fixed compilation error when using libphonenumber from revision
>= 568" patch caused a double free error because SetLogger() owns the
logger instance and, with libphonenumber >= r571 actually frees the
instance.

Old libphonenumber release are compatible with the revised call,
however, they never free the instance.
This commit is contained in:
Patrick Ohly 2014-06-25 12:24:25 +02:00
parent d8c8e153ea
commit 944281a024
1 changed files with 7 additions and 1 deletions

View File

@ -1022,7 +1022,13 @@ public:
// Redirect output of libphonenumber and make it a bit quieter
// than it is by default. We map fatal libphonenumber errors
// to ERROR and everything else to DEBUG.
i18n::phonenumbers::PhoneNumberUtil::GetInstance()->SetLogger(&m_logger);
//
// The PhoneNumberUtil instance owns the logger, so we don't
// need (and must not) free it. libphonenumber < r571 has the
// same API and thus this code compiles. However, older
// libphonenumer does not actually free the instance, causing
// a minor memory leak.
i18n::phonenumbers::PhoneNumberUtil::GetInstance()->SetLogger(new PhoneNumberLogger);
}
static std::locale genLocale()