--- cmd-load-buffer.c	2010-02-19 16:54:21.000000000 +0100
+++ cmd-load-buffer.c.fulvio	2010-02-19 16:53:57.000000000 +0100
@@ -47,7 +47,7 @@
 	struct session		*s;
 	FILE			*f;
 	char		      	*pdata, *new_pdata;
-	size_t			 psize;
+	size_t			 psize,bufsize;
 	u_int			 limit;
 	int			 ch;
 
@@ -61,13 +61,17 @@
 
 	pdata = NULL;
 	psize = 0;
+  bufsize = 0;
 	while ((ch = getc(f)) != EOF) {
 		/* Do not let the server die due to memory exhaustion. */
-		if ((new_pdata = realloc(pdata, psize + 2)) == NULL) {
+    if (psize+2>bufsize) {
+      bufsize=2*bufsize+64;
+      if ((new_pdata = realloc(pdata, bufsize)) == NULL) {
 			ctx->error(ctx, "realloc error: %s", strerror(errno));
 			goto error;
-		}
-		pdata = new_pdata;
+      }
+      pdata = new_pdata;
+    }
 		pdata[psize++] = ch;
 	}
 	if (ferror(f)) {
