[gmime] cap max cache size to G_MAXSIZE



commit 4030678428931e93d5194ab9fa3cd3b22f17a429
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Sat May 2 13:44:34 2009 -0400

    cap max cache size to G_MAXSIZE
---
 ChangeLog                   |    1 +
 gmime/gmime-stream-buffer.c |    8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0fd996e..a13405a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
 	* gmime/gmime-stream-buffer.c (stream_seek_cache_read): Fixed a
 	64bit cleanlines issue.
+	(stream_seek_cache_read): Cap the max cache size to G_MAXSIZE.
 
 2009-04-30  Jeffrey Stedfast  <fejj novell com>
 
diff --git a/gmime/gmime-stream-buffer.c b/gmime/gmime-stream-buffer.c
index d6098cf..f2144ee 100644
--- a/gmime/gmime-stream-buffer.c
+++ b/gmime/gmime-stream-buffer.c
@@ -489,7 +489,7 @@ static gint64
 stream_seek_cache_read (GMimeStream *stream, gint64 offset, GMimeSeekWhence whence)
 {
 	GMimeStreamBuffer *buffer = (GMimeStreamBuffer *) stream;
-	gint64 len, total = 0;
+	gint64 buflen, len, total = 0;
 	gint64 pos, real;
 	ssize_t nread;
 	
@@ -538,7 +538,11 @@ stream_seek_cache_read (GMimeStream *stream, gint64 offset, GMimeSeekWhence when
 		
 		pos = buffer->bufptr - buffer->buffer;
 		
-		buffer->buflen = buffer->bufend - buffer->buffer + len;
+		buflen = (buffer->bufend - buffer->buffer) + len;
+		if (buflen < G_MAXSIZE)
+			buffer->buflen = (size_t) buflen;
+		else
+			buffer->buflen = G_MAXSIZE;
 		
 		buffer->buffer = g_realloc (buffer->buffer, buffer->buflen);
 		buffer->bufend = buffer->buffer + buffer->buflen;



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