Re: g_io_channel_read_to_end read just 998 chars, not more



Hi frederico,

On Thu, 27 May 2010 11:02:47 -0300 you wrote:
> > Why don't you test the error returns?
> GError *b = NULL;
> 
> g_io_channel_read_to_end( channel, &string, &size, &b);
> 
> g_print("returned: %s\nsize: %d\nerror: %s", string, size, b->message);
> 
> It causes segmentation fault. What I'm doing wrong here?

You're not testing the error return. If the g_io_channel_read_to_end completes without error, then it doesn't change 'b', so the printf is doing a de-reference of a NULL pointer. You should change it to :

GError *b = NULL;

g_io_channel_read_to_end( channel, &string, &size, &b);

g_print("returned: %s\nsize: %d\n", string, size );
if ( b )
    g_print("error: %s\n", b->message);


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