aboutsummaryrefslogtreecommitdiff
path: root/src/rc-misc.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-10-12 00:01:33 +0000
committerRoy Marples <roy@marples.name>2007-10-12 00:01:33 +0000
commit20a149b2c7bfd7e53d24d0665281c083d7362c67 (patch)
treeb195111871b8e05c584b71aed066c3990c5db2b3 /src/rc-misc.c
parente3bc6666d6d5bd8922ca10652a2d04577357fa71 (diff)
malloc over fatty buffers
Diffstat (limited to 'src/rc-misc.c')
-rw-r--r--src/rc-misc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/rc-misc.c b/src/rc-misc.c
index 60f8009a..1012f57c 100644
--- a/src/rc-misc.c
+++ b/src/rc-misc.c
@@ -132,7 +132,7 @@ char **env_filter (void)
static bool file_regex (const char *file, const char *regex)
{
FILE *fp;
- char buffer[RC_LINEBUFFER];
+ char *buffer;
regex_t re;
bool retval = false;
int result;
@@ -140,10 +140,12 @@ static bool file_regex (const char *file, const char *regex)
if (! (fp = fopen (file, "r")))
return (false);
+ buffer = xmalloc (sizeof (char) * RC_LINEBUFFER);
if ((result = regcomp (&re, regex, REG_EXTENDED | REG_NOSUB)) != 0) {
fclose (fp);
- regerror (result, &re, buffer, sizeof (buffer));
+ regerror (result, &re, buffer, RC_LINEBUFFER);
fprintf (stderr, "file_regex: %s", buffer);
+ free (buffer);
return (false);
}
@@ -154,6 +156,7 @@ static bool file_regex (const char *file, const char *regex)
break;
}
}
+ free (buffer);
fclose (fp);
regfree (&re);