--- camel-stub-marshal.c	2006-07-05 10:12:59.000000000 +0530
+++ camel-stub-marshal.c.new	2006-07-05 10:12:48.000000000 +0530
@@ -111,6 +111,7 @@ marshal_read (CamelStubMarshal *marshal,
 
 	if (avail == 0) {
 		g_byte_array_set_size (marshal->in, 4);
+		marshal->inptr = (char *)marshal->in->data + 4;
 		if (!do_read (marshal, (char *)marshal->in->data, 4))
 			return -1;
 		avail =  (int)marshal->in->data[0]        +
@@ -118,9 +119,12 @@ marshal_read (CamelStubMarshal *marshal,
 			((int)marshal->in->data[2] << 16) +
 			((int)marshal->in->data[3] << 24) - 4;
 		g_byte_array_set_size (marshal->in, avail + 4);
-		if (!do_read (marshal, ((char *)marshal->in->data) + 4, avail))
-			return -1;
 		marshal->inptr = (char *)marshal->in->data + 4;
+		if (!do_read (marshal, ((char *)marshal->in->data) + 4, avail)) {
+			g_byte_array_set_size (marshal->in, 4);
+			marshal->inptr = (char *)marshal->in->data + 4;
+			return -1;
+		}
 	}
 
 	if (len <= avail)
