From 20a149b2c7bfd7e53d24d0665281c083d7362c67 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 12 Oct 2007 00:01:33 +0000 Subject: malloc over fatty buffers --- src/rc-plugin.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/rc-plugin.c') diff --git a/src/rc-plugin.c b/src/rc-plugin.c index 8bd50849..1cdf5690 100644 --- a/src/rc-plugin.c +++ b/src/rc-plugin.c @@ -150,15 +150,16 @@ void rc_plugin_run (rc_hook_t hook, const char *value) rc_in_plugin = true; exit (retval); } else { - char buffer[RC_LINEBUFFER]; + char *buffer; char *token; char *p; ssize_t nr; close (pfd[1]); - memset (buffer, 0, sizeof (buffer)); + buffer = xmalloc (sizeof (char) * RC_LINEBUFFER); + memset (buffer, 0, RC_LINEBUFFER); - while ((nr = read (pfd[0], buffer, sizeof (buffer))) > 0) { + while ((nr = read (pfd[0], buffer, RC_LINEBUFFER)) > 0) { p = buffer; while (*p && p - buffer < nr) { token = strsep (&p, "="); @@ -172,7 +173,8 @@ void rc_plugin_run (rc_hook_t hook, const char *value) } } } - + + free (buffer); close (pfd[0]); } } -- cgit v1.2.3