From 8e008e868d747a7dfc5d6be37dc01a2209632f83 Mon Sep 17 00:00:00 2001 From: NotZed Date: Thu, 10 Feb 2000 02:15:02 +0000 Subject: If we get a -1 read, DONT update the total bytes, and try and truncate the 2000-02-09 NotZed * camel/camel-mime-part-utils.c (camel_mime_part_store_stream_in_buffer): If we get a -1 read, DONT update the total bytes, and try and truncate the array in reverse. Eek. * camel/camel-mime-part.c (camel_mime_part_encoding_from_string): This was DEFINETLEY not the right way to do it. strncmp!=strcmp (camel_mime_part_encoding_to_string): Handle the default case. : include string.h for strcmp() etc. svn path=/trunk/; revision=1720 --- camel/camel-mime-part-utils.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'camel/camel-mime-part-utils.c') diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c index 5e6d187a11..463aa7cb3c 100644 --- a/camel/camel-mime-part-utils.c +++ b/camel/camel-mime-part-utils.c @@ -150,21 +150,24 @@ camel_mime_part_store_stream_in_buffer (CamelMimePart *mime_part, mime_part->temp_message_buffer = g_byte_array_new (); buffer = mime_part->temp_message_buffer; - + g_byte_array_set_size (buffer, nb_bytes_read_total + STREAM_READ_CHUNK_SZ); nb_bytes_read_chunk = camel_stream_read (stream, buffer->data + nb_bytes_read_total, STREAM_READ_CHUNK_SZ); - nb_bytes_read_total += nb_bytes_read_chunk; - while (nb_bytes_read_chunk >0) { - g_byte_array_set_size (buffer, nb_bytes_read_total + STREAM_READ_CHUNK_SZ); - nb_bytes_read_chunk = camel_stream_read (stream, - buffer->data + nb_bytes_read_total, - STREAM_READ_CHUNK_SZ); + if (nb_bytes_read_chunk>0) { nb_bytes_read_total += nb_bytes_read_chunk; + + while (nb_bytes_read_chunk >0) { + g_byte_array_set_size (buffer, nb_bytes_read_total + STREAM_READ_CHUNK_SZ); + nb_bytes_read_chunk = camel_stream_read (stream, + buffer->data + nb_bytes_read_total, + STREAM_READ_CHUNK_SZ); + nb_bytes_read_total += nb_bytes_read_chunk; + } } - + g_byte_array_set_size (buffer, nb_bytes_read_total); CAMEL_LOG_FULL_DEBUG ("CamelMimePartUtils::store_stream_in_buffer entering\n"); -- cgit v1.2.3