Index: ut_stringbuf.cpp =================================================================== --- ut_stringbuf.cpp (revision 29473) +++ ut_stringbuf.cpp (working copy) @@ -349,6 +349,7 @@ size_t i; for (i = 0; (i < n) || (n == 0); i++) { + if (sz[i]==0 && n==0) break; int seql = UT_Unicode::UTF8_ByteLength ((UT_UCS4Char)sz[i]); if (seql < 0) continue; // not UCS-4 !! @@ -356,10 +357,12 @@ break; // end-of-string? bytelength += static_cast(seql); } + if (!grow (bytelength + 1)) return; for (i = 0; (i < n) || (n == 0); i++) { + if (sz[i]==0 && n==0) break; int seql = UT_Unicode::UTF8_ByteLength ((UT_UCS4Char)sz[i]); if (seql < 0) continue; // not UCS-4 !!