glib's g_logv 1024 byte maximum character array



I had a bug reported against my application which basically meant that
information being written to a iochannel was not valid UTF8.  

I narrowed it down, checking the text at every stage and the buffer was
valid UTF8 up until the point I call g_message("%s", buffer) with it.  

The 'buffer' argument is more than 1024 bytes in this particular case, and
when I check the message which has passed through the g_log() functions I
notice that it is no more than 1024 bytes.  

I check the Glib code to find that it has a character array with a maximum
size of 1025 bytes and this array is used in the function _g_vsnprintf(), on
line 437 here:
http://cvs.gnome.org/bonsai/cvsblame.cgi?file=glib%2Fglib/gmessages.c&rev=&r
oot=/cvs/gnome

The problem I face is that I am passing an argument which is more than 1025
bytes and is filled with multibyte characters.  I suspect the reason I get
an "invalid utf8" error is because at the 1024th byte, it is half way
through a (in this case Russian) multibyte character, causing incomplete
UTF8 characters and hence, invalid UTF8.

Should I be limiting all my arguments to 1024 bytes? or should this be an
improvement in Glib?

Regards,
Martyn




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]