gmime r1236 - in trunk: . gmime



Author: fejj
Date: Fri May 16 15:22:30 2008
New Revision: 1236
URL: http://svn.gnome.org/viewvc/gmime?rev=1236&view=rev

Log:
2008-05-15  Jeffrey Stedfast  <fejj novell com>

	* gmime/gmime-stream-buffer.c (stream_read): Break if
	g_mime_stream_read() returns 0 as well (meaning EOF, no more data
	to read) and don't keep looping. Fixes bug #533331.



Modified:
   trunk/ChangeLog
   trunk/gmime/gmime-stream-buffer.c
   trunk/gmime/gmime-stream-file.c

Modified: trunk/gmime/gmime-stream-buffer.c
==============================================================================
--- trunk/gmime/gmime-stream-buffer.c	(original)
+++ trunk/gmime/gmime-stream-buffer.c	Fri May 16 15:22:30 2008
@@ -173,9 +173,9 @@
 				buffer->bufptr = buffer->buffer;
 			}
 			
-			if (n == -1) {
+			if (n <= 0) {
 				if (nread == 0)
-					return -1;
+					return n;
 				
 				break;
 			}
@@ -204,9 +204,9 @@
 				
 				buffer->bufend = n > 0 ? buffer->bufptr + n : buffer->bufptr;
 				
-				if (n == -1) {
+				if (n <= 0) {
 					if (nread == 0)
-						return -1;
+						return n;
 					
 					break;
 				}
@@ -685,10 +685,8 @@
 					/* buffer more data */
 					buffer->bufptr = buffer->buffer;
 					n = g_mime_stream_read (buffer->source, buffer->buffer, BLOCK_BUFFER_LEN);
-					if (n <= 0) {
-						buffer->buflen = 0;
+					if (n <= 0)
 						break;
-					}
 					
 					buffer->buflen = n;
 				}
@@ -742,10 +740,6 @@
 			*outptr++ = c;
 	}
 	
-	/* strip \r */
-	if (c == '\n' && outptr > buf && outptr[-1] == '\r')
-		outptr--;
-	
 	if (outptr <= outend) {
 		/* this should always be true unless @max == 0 */
 		*outptr = '\0';

Modified: trunk/gmime/gmime-stream-file.c
==============================================================================
--- trunk/gmime/gmime-stream-file.c	(original)
+++ trunk/gmime/gmime-stream-file.c	Fri May 16 15:22:30 2008
@@ -129,7 +129,7 @@
 stream_read (GMimeStream *stream, char *buf, size_t len)
 {
 	GMimeStreamFile *fstream = (GMimeStreamFile *) stream;
-	ssize_t nread;
+	size_t nread;
 	
 	if (stream->bound_end != -1 && stream->position >= stream->bound_end)
 		return -1;
@@ -143,14 +143,14 @@
 	if ((nread = fread (buf, 1, len, fstream->fp)) > 0)
 		stream->position += nread;
 	
-	return nread;
+	return (ssize_t) nread;
 }
 
 static ssize_t
 stream_write (GMimeStream *stream, const char *buf, size_t len)
 {
 	GMimeStreamFile *fstream = (GMimeStreamFile *) stream;
-	ssize_t nwritten;
+	size_t nwritten;
 	
 	if (stream->bound_end != -1 && stream->position >= stream->bound_end)
 		return -1;
@@ -164,7 +164,7 @@
 	if ((nwritten = fwrite (buf, 1, len, fstream->fp)) > 0)
 		stream->position += nwritten;
 	
-	return nwritten;
+	return (ssize_t) nwritten;
 }
 
 static int



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