libaegisub: Avoid calling iconv_close(iconv_invalid)

IsConversionSupported unconditionally calls iconv_close on the
descriptor returned by iconv_open. This may result in crashes if
iconv_open returns iconv_invalid.
This commit is contained in:
Alex James 2023-08-14 19:49:10 -05:00 committed by arch1t3cht
parent 47c923d4ed
commit 4f67db8dd7

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;
}