diff --git a/Source/GSString.m b/Source/GSString.m index 7cd81242c..c5b3d82d0 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -1264,8 +1264,8 @@ lossyCString_u(ivars self) unsigned l = 0; unsigned char *r = 0; - GSFromUnicode(&r, &l, self->_contents.u, self->_count, defEnc, 0, - GSUniTemporary|GSUniTerminate); + GSFromUnicode(&r, &l, self->_contents.u, self->_count, defEnc, + NSDefaultMallocZone(), GSUniTemporary|GSUniTerminate); return (const char*)r; } diff --git a/Source/Unicode.m b/Source/Unicode.m index 6981b2311..ceca4d50d 100644 --- a/Source/Unicode.m +++ b/Source/Unicode.m @@ -1621,9 +1621,10 @@ tables: GROW(); outbuf = (char*)&ptr[dpos]; - outbytesleft = (bsize - old) * sizeof(unichar); + outbytesleft += (bsize - old) * sizeof(unichar); } rval = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + dpos = (bsize * sizeof(unichar) - outbytesleft) / sizeof(unichar); if (rval == (size_t)-1) { if (errno == E2BIG) @@ -1632,7 +1633,7 @@ tables: GROW(); outbuf = (char*)&ptr[dpos]; - outbytesleft = (bsize - old) * sizeof(unichar); + outbytesleft += (bsize - old) * sizeof(unichar); } else { @@ -1640,7 +1641,6 @@ tables: break; } } - dpos = (bsize * sizeof(unichar) - outbytesleft) / sizeof(unichar); } // close the converter iconv_close(cd); @@ -2141,9 +2141,10 @@ tables: GROW(); outbuf = (char*)&ptr[dpos]; - outbytesleft = (bsize - old); + outbytesleft += (bsize - old); } rval = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + dpos = bsize - outbytesleft; if (rval == (size_t)-1) { if (errno == E2BIG) @@ -2152,7 +2153,7 @@ tables: GROW(); outbuf = (char*)&ptr[dpos]; - outbytesleft = (bsize - old); + outbytesleft += (bsize - old); } else if (errno == EILSEQ) { @@ -2179,7 +2180,6 @@ tables: break; } } - dpos = bsize - outbytesleft; } // close the converter iconv_close(cd); diff --git a/Testing/nsconnection_client.m b/Testing/nsconnection_client.m index 622d6a780..ed27eb369 100644 --- a/Testing/nsconnection_client.m +++ b/Testing/nsconnection_client.m @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "server.h" diff --git a/Testing/string.m b/Testing/string.m index 6ae8258ef..97dc9169f 100644 --- a/Testing/string.m +++ b/Testing/string.m @@ -95,6 +95,9 @@ int main() printf("%x,%x\n", [base characterAtIndex: i], [want characterAtIndex: i]); printf("%u\n", [want isEqual: base]); + for (i = 0; i < 1000; i++) + [base appendString: want]; + print_string(base); } [arp release]; exit(0);