From 4f67db8dd732efbace81aa57260b6575fe86dd55 Mon Sep 17 00:00:00 2001 From: Alex James Date: Mon, 14 Aug 2023 19:49:10 -0500 Subject: [PATCH] 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. --- libaegisub/common/charset_conv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libaegisub/common/charset_conv.cpp b/libaegisub/common/charset_conv.cpp index 47644eb1c9..f19090c154 100644 --- a/libaegisub/common/charset_conv.cpp +++ b/libaegisub/common/charset_conv.cpp @@ -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; }