]> git.lyx.org Git - features.git/commitdiff
* src/support/unicode.C
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Thu, 28 Dec 2006 07:35:57 +0000 (07:35 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Thu, 28 Dec 2006 07:35:57 +0000 (07:35 +0000)
(iconv_convert): Fix a crash: Don't try to create a vector from two
pointers where end is before begin.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16408 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/unicode.C

index 6e814a7b9f0072ddc06f8218789c15f599113544..0ddeadffbc9c3e8aa02f3422c0ad1333c8158d9a 100644 (file)
@@ -203,6 +203,10 @@ iconv_convert(IconvProcessor & processor,
        char * outbuf = out;
 
        int bytes = processor.convert(inbuf, inbytesleft, outbuf, outsize);
+       if (bytes <= 0)
+               // Conversion failed
+               // FIXME Maybe throw an exception and handle that in the caller?
+               return std::vector<RetType>();
 
        RetType const * tmp = reinterpret_cast<RetType const *>(out);
        return std::vector<RetType>(tmp, tmp + bytes / sizeof(RetType));