After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 58472 - g_io_channeal_read_line* error in "UTF-8" encoding
g_io_channeal_read_line* error in "UTF-8" encoding
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
1.3.x
Other Solaris
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 58195
 
 
Reported: 2001-08-03 01:34 UTC by Hidetoshi Tajima
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
always use encoded_read_buf (784 bytes, patch)
2001-08-03 01:46 UTC, Hidetoshi Tajima
none Details | Review

Description Hidetoshi Tajima 2001-08-03 01:34:58 UTC
g_io_channel_read_line and g_io_channel_read_line_string
causes error:
  GLib-CRITICAL **: file gstring.c: line 623 
   (g_string_erase): assertion `pos + len <= string->len' failed

with default encoding "UTF-8" .

To reproduce, comment out a line below of io-channel.c.

     g_io_channel_set_encoding (gio_r, encoding, &gerr);
Comment 1 Hidetoshi Tajima 2001-08-03 01:42:07 UTC
A patch to giochannel.c will be attached for code review.

channel->encoded_read_buf should always
be used regardless of do_encode flag, 
as channel->read_buf was already copied 
to it and deleted  in g_io_channel_fill_buffer
(line 1199).
Comment 2 Hidetoshi Tajima 2001-08-03 01:46:12 UTC
Created attachment 839 [details] [review]
always use encoded_read_buf
Comment 3 Ron Steinke 2001-08-03 20:05:12 UTC
This isn't quite correct. encoded_read_buf isn't used at
all if the encoding is NULL. The test needs to be changed
from channel->do_encode to channel->encoding instead.
Comment 4 Hidetoshi Tajima 2001-08-03 20:16:44 UTC
When I set "UTF-8" to io channel or don't set encoding at all,
g_io_channel_read_line_string or g_io_channel_read_line
causes error.  I think the patch may not do a right thing,
but actually makes the above case work. 
I don't think the case of channel->encoding == NULL
should occur in the current code. g_io_channel_init
initializes this to "UTF-8" and  setting NULL encoding
with g_io_channel_set_encoding should not work.
Comment 5 Ron Steinke 2001-08-03 20:47:00 UTC
Setting an encoding of NULL makes GIOChannel binary safe.
Changing the test from "if (channel->do_encode)" to
"if (channel->encoding)" makes use_buf equal to
encoded_read_buf for UTF-8, and equal to read_buf
for NULL. I've committed a fix which works for both
NULL and UTF-8 to CVS.
Comment 6 Hidetoshi Tajima 2001-08-03 21:20:32 UTC
I verified the fix in revision 1.1.8 of giochannel.[ch].
marked the bug fixed.http://bugzilla.gnome.org/bug_status.html