Hello,
I had a crash in utf8_to_ucs4() when loading a document which had an
empty inset apparently (Intro.lyx). The following commit adds some
sanity checks to unicode.C.
Abdel.
URL: http://www.lyx.org/trac/changeset/15362
Log:
add some sanity checks.
Modified:
lyx-devel/trunk/src/support/unicode.C
Modified: lyx-devel/trunk/src/support/unicode.C
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/support/unicode.C?rev=15362
==============================================================================
--- lyx-devel/trunk/src/support/unicode.C (original)
+++ lyx-devel/trunk/src/support/unicode.C Wed Oct 18 14:06:04 2006
@@ -127,6 +127,9 @@
std::vector<lyx::char_type> utf8_to_ucs4(std::vector<char> const &
utf8str)
{
+ if (utf8str.empty())
+ return std::vector<lyx::char_type>();
+
return utf8_to_ucs4(&utf8str[0], utf8str.size());
}
@@ -150,6 +153,9 @@
std::vector<lyx::char_type>
ucs2_to_ucs4(std::vector<unsigned short> const & ucs2str)
{
+ if (ucs2str.empty())
+ return std::vector<lyx::char_type>();
+
return ucs2_to_ucs4(&ucs2str[0], ucs2str.size());
}
@@ -173,6 +179,9 @@
std::vector<unsigned short>
ucs4_to_ucs2(std::vector<lyx::char_type> const & ucs4str)
{
+ if (ucs4str.empty())
+ return std::vector<unsigned short>();
+
return ucs4_to_ucs2(&ucs4str[0], ucs4str.size());
}
@@ -197,6 +206,9 @@
std::vector<char>
ucs4_to_utf8(std::vector<lyx::char_type> const & ucs4str)
{
+ if (ucs4str.empty())
+ return std::vector<char>();
+
return ucs4_to_utf8(&ucs4str[0], ucs4str.size());
}