🐛 Fix: lagi: Don't close iconv_t if it is iconv_invalid

When certain iconv_t is invalid, iconv_invalid(0xfffffffffffffffffffffff) will be returned. Passing it to iconv_close will cause a SIGSEGV.
This commit is contained in:
Charlie Jiang 2019-10-06 23:47:53 +08:00 committed by wangqr
parent 71894fd769
commit a2fc4bf479

View file

@ -420,7 +420,7 @@ size_t IconvWrapper::DstStrLen(const char* str) {
bool IsConversionSupported(const char *src, const char *dst) {
iconv_t cd = iconv_open(dst, src);
bool supported = cd != iconv_invalid;
iconv_close(cd);
if (supported) iconv_close(cd);
return supported;
}