From 621f2ac3ffbec9d52a305ed1f9d0782d55c97ae1 Mon Sep 17 00:00:00 2001 From: brenosilva Date: Mon, 27 Feb 2012 16:58:05 +0000 Subject: [PATCH] Fix mlogc 100 cpu problem --- mlogc/mlogc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mlogc/mlogc.c b/mlogc/mlogc.c index 3e2502bf..8a30f091 100644 --- a/mlogc/mlogc.c +++ b/mlogc/mlogc.c @@ -421,8 +421,10 @@ static int read_queue_entries(apr_file_t *fd, apr_time_t *queue_time) { char linebuf[4100]; int line_count = -1; + int line_size = 0; for(;;) { + memset(linebuf, 0, 4100); apr_status_t rc = apr_file_gets(linebuf, 4096, fd); char *p; @@ -440,14 +442,16 @@ static int read_queue_entries(apr_file_t *fd, apr_time_t *queue_time) } p = &linebuf[0]; + line_size = strlen(p); /* Remove the \n from the end of the line. */ - while(*p != '\0') { + while(*p != '\0' && line_size > 0) { if (*p == '\n') { *p = '\0'; break; } p++; + line_size--; } if (linebuf[0] == '#') { /* Ignore comments. */