Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
Ensure we always have some target space in GConverterOutputStream
Browse files Browse the repository at this point in the history
When the converter fills the whole buffer without reading all input,
we need to enlarge the buffer. Otherwise we get an assertion failure
for `outbuf_size > 0' in g_converter_convert.

https://bugzilla.gnome.org/show_bug.cgi?id=619945
(cherry picked from commit 86592d6)
  • Loading branch information
juergbi authored and alexlarsson committed Jun 11, 2010
1 parent f06f37e commit efff840
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gio/gconverteroutputstream.c
Expand Up @@ -418,6 +418,10 @@ g_converter_output_stream_write (GOutputStream *stream,
converted_bytes = 0;
while (!priv->finished && converted_bytes < to_convert_size)
{
/* Ensure we have *some* target space */
if (buffer_tailspace (&priv->converted_buffer) == 0)
grow_buffer (&priv->converted_buffer);

/* Try to convert to our buffer */
my_error = NULL;
res = g_converter_convert (priv->converter,
Expand Down Expand Up @@ -529,6 +533,10 @@ g_converter_output_stream_flush (GOutputStream *stream,
flushed = FALSE;
while (!priv->finished && !flushed)
{
/* Ensure we have *some* target space */
if (buffer_tailspace (&priv->converted_buffer) == 0)
grow_buffer (&priv->converted_buffer);

/* Try to convert to our buffer */
my_error = NULL;
res = g_converter_convert (priv->converter,
Expand Down

0 comments on commit efff840

Please sign in to comment.