# HG changeset patch # User Mikael Berthe # Date 1135943208 -3600 # Node ID ebbe3845b46b341a39397b234bae40b87f59ee2c # Parent 62679532ea55de55c07fbc45cfbbcfaae9122e28 Fix a crash when a resource contains non-representable chars diff -r 62679532ea55 -r ebbe3845b46b mcabber/src/jabglue.c --- a/mcabber/src/jabglue.c Wed Dec 28 19:05:11 2005 +0100 +++ b/mcabber/src/jabglue.c Fri Dec 30 12:46:48 2005 +0100 @@ -1394,14 +1394,20 @@ if (m++) { s = from_utf8(m); if (s) { - // The length should be enough because from_utf should only - // reduce the string length + // In some cases the allocated memory size could be too small because + // when chars cannot be converted strings like "\uxxxx" or "\Uxxxxyyyy" + // are used. + if (strlen(r+1) < strlen(s)) { + from = g_realloc(from, 1+m-p+strlen(s)); + r = strchr(from, '/'); + } strcpy(r+1, s); g_free(s); } else { *(r+1) = 0; scr_LogPrint(LPRINT_NORMAL, "Decoding of message sender has failed"); - scr_LogPrint(LPRINT_LOG, "Decoding of message sender has failed: %s", m); + scr_LogPrint(LPRINT_LOG, "Decoding of message sender has failed: %s", + m); } } }