diff options
author | Roy Marples <roy@marples.name> | 2007-10-12 00:01:33 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-10-12 00:01:33 +0000 |
commit | 20a149b2c7bfd7e53d24d0665281c083d7362c67 (patch) | |
tree | b195111871b8e05c584b71aed066c3990c5db2b3 /src/rc-plugin.c | |
parent | e3bc6666d6d5bd8922ca10652a2d04577357fa71 (diff) |
malloc over fatty buffers
Diffstat (limited to 'src/rc-plugin.c')
-rw-r--r-- | src/rc-plugin.c | 10 |
1 files changed, 6 insertions, 4 deletions
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]); } } |