Matthew Barnes 26efb9
--- evolution-data-server-1.8.0/camel/camel-object.c.fix-camel-malloc	2006-09-26 16:26:00.000000000 -0400
Matthew Barnes 26efb9
+++ evolution-data-server-1.8.0/camel/camel-object.c	2006-09-26 16:35:32.000000000 -0400
Matthew Barnes 26efb9
@@ -455,9 +455,13 @@
Matthew Barnes 26efb9
 			/* maybe it was just version 0 afterall */
Matthew Barnes 26efb9
 			return 0;
Matthew Barnes 26efb9
 		}
Matthew Barnes 26efb9
+
Matthew Barnes 26efb9
+		count = MIN(count, CAMEL_ARGV_MAX);
Matthew Barnes 26efb9
 		
Matthew Barnes 26efb9
 		/* we batch up the properties and set them in one go */
Matthew Barnes 26efb9
-		if (!(argv = g_try_malloc ((gulong)(sizeof (*argv) + (count - CAMEL_ARGV_MAX) * sizeof (argv->argv[0])))))
Matthew Barnes 26efb9
+		argv = g_try_malloc(sizeof(CamelArgV) -
Matthew Barnes 26efb9
+			((CAMEL_ARGV_MAX - count) * sizeof(CamelArg)));
Matthew Barnes 26efb9
+		if (argv == NULL)
Matthew Barnes 26efb9
 			return -1;
Matthew Barnes 26efb9
 		
Matthew Barnes 26efb9
 		argv->argc = 0;
Matthew Barnes 26efb9
@@ -536,9 +540,12 @@
Matthew Barnes 26efb9
 	   we also need an argv to store the results - bit messy */
Matthew Barnes 26efb9
 
Matthew Barnes 26efb9
 	count = g_slist_length(props);
Matthew Barnes 26efb9
+	count = MIN(count, CAMEL_ARGV_MAX);
Matthew Barnes 26efb9
 
Matthew Barnes 26efb9
-	arggetv = g_malloc0(sizeof(*arggetv) + (count - CAMEL_ARGV_MAX) * sizeof(arggetv->argv[0]));
Matthew Barnes 26efb9
-	argv = g_malloc0(sizeof(*argv) + (count - CAMEL_ARGV_MAX) * sizeof(argv->argv[0]));
Matthew Barnes 26efb9
+	arggetv = g_malloc0(sizeof(CamelArgGetV) -
Matthew Barnes 26efb9
+		((CAMEL_ARGV_MAX - count) * sizeof(CamelArgGet)));
Matthew Barnes 26efb9
+	argv = g_malloc0(sizeof(CamelArgV) -
Matthew Barnes 26efb9
+		((CAMEL_ARGV_MAX - count) * sizeof(CamelArg)));
Matthew Barnes 26efb9
 	l = props;
Matthew Barnes 26efb9
 	i = 0;
Matthew Barnes 26efb9
 	while (l) {