aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-parser.c
diff options
context:
space:
mode:
author5 <notzed@helixcode.com>2000-05-05 15:28:20 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-05-05 15:28:20 +0800
commit022c7ab1f28ac677a60cbffa54be28e3272f1c2d (patch)
tree78c6c3858166812bbe3728e27d0677fba0e9c1b8 /camel/camel-mime-parser.c
parent4a6a526998c160dd1fd8353cee2532206bb36c8e (diff)
downloadgsoc2013-evolution-022c7ab1f28ac677a60cbffa54be28e3272f1c2d.tar
gsoc2013-evolution-022c7ab1f28ac677a60cbffa54be28e3272f1c2d.tar.gz
gsoc2013-evolution-022c7ab1f28ac677a60cbffa54be28e3272f1c2d.tar.bz2
gsoc2013-evolution-022c7ab1f28ac677a60cbffa54be28e3272f1c2d.tar.lz
gsoc2013-evolution-022c7ab1f28ac677a60cbffa54be28e3272f1c2d.tar.xz
gsoc2013-evolution-022c7ab1f28ac677a60cbffa54be28e3272f1c2d.tar.zst
gsoc2013-evolution-022c7ab1f28ac677a60cbffa54be28e3272f1c2d.zip
Plug a memory leak. (header_decode_text): Fixed memory leaks with
2000-05-05 <notzed@helixcode.com> * camel-mime-utils.c (header_decode_mailbox): Plug a memory leak. (header_decode_text): Fixed memory leaks with g_string_append(). (header_encode_string): And here too, and a few other places. The glib api is so awful ... (header_content_type_decode): More memory leaks, more left ... 2000-05-05 <notzed@helixcode.com> * camel-mime-parser.c (folder_scan_init_with_fd): Make sure we init the end of buffer sentinal! (folder_scan_init_with_stream): And here too ... svn path=/trunk/; revision=2810
Diffstat (limited to 'camel/camel-mime-parser.c')
-rw-r--r--camel/camel-mime-parser.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index 95ecc4d994..73a1172adb 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -46,9 +46,10 @@
#define c(x)
#define d(x)
-/*#define MEMPOOL*/
+#define MEMPOOL
+
+#define STRUCT_ALIGN 4
-#if 0
extern int strdup_count;
extern int malloc_count;
extern int free_count;
@@ -57,8 +58,6 @@ extern int free_count;
#define g_malloc(x) (malloc_count++, g_malloc(x))
#define g_free(x) (free_count++, g_free(x))
-#endif
-
#ifdef MEMPOOL
typedef struct _MemPoolNode {
@@ -101,6 +100,7 @@ MemPool *mempool_new(int blocksize, int threshold)
void *mempool_alloc(MemPool *pool, int size)
{
+ size = (size + STRUCT_ALIGN) & (~(STRUCT_ALIGN-1));
if (size>=pool->threshold) {
MemPoolThresholdNode *n;
@@ -809,6 +809,9 @@ folder_read(struct _header_scan_state *s)
s->inend = s->inbuf+len+inoffset;
r(printf("content = %d '%.*s'\n",s->inend - s->inptr, s->inend - s->inptr, s->inptr));
}
+
+ g_assert(s->inptr<=s->inend);
+
r(printf("content = %d '%.*s'\n", s->inend - s->inptr, s->inend - s->inptr, s->inptr));
/* set a sentinal, for the inner loops to check against */
s->inend[0] = '\n';
@@ -1071,8 +1074,8 @@ retry:
;
/* check against the real buffer end, not our 'atleast limited' end */
- if (inptr>= s->inend) {
- inptr--;
+ if (inptr> s->inend) {
+ inptr-=2;
s->midline = TRUE;
} else {
s->midline = FALSE;
@@ -1357,6 +1360,8 @@ folder_scan_init_with_fd(struct _header_scan_state *s, int fd)
len = read(fd, s->inbuf, SCAN_BUF);
if (len>=0) {
s->inend = s->inbuf+len;
+ s->inptr = s->inbuf;
+ s->inend[0] = '\n';
if (s->fd != -1)
close(s->fd);
s->fd = fd;
@@ -1378,6 +1383,8 @@ folder_scan_init_with_stream(struct _header_scan_state *s, CamelStream *stream)
len = camel_stream_read(stream, s->inbuf, SCAN_BUF);
if (len>=0) {
s->inend = s->inbuf+len;
+ s->inptr = s->inbuf;
+ s->inend[0] = '\n';
if (s->stream)
gtk_object_unref((GtkObject *)s->stream);
s->stream = stream;