diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-11-19 16:56:45 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-11-19 16:56:45 +0100 |
commit | 5254928eed42186869555ac082eb184dd4522ac3 (patch) | |
tree | 948ab550840d1f3da6c7f412cd9d04cd3aea3565 /src | |
parent | 817d21852cef6663f6e58cc4911412e3f80f9f2e (diff) |
add proper buffer handling in CssContext::buildUserStyle()
Diffstat (limited to 'src')
-rw-r--r-- | src/css.cc | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -11,6 +11,7 @@ #include <stdio.h> #include <math.h> +#include "../dlib/dlib.h" #include "prefs.h" #include "html_common.hh" #include "css.hh" @@ -207,19 +208,20 @@ void CssContext::buildUserAgentStyle () { } void CssContext::buildUserStyle () { - char *buf; + char buf[1024]; char *filename; filename = dStrconcat(dGethomedir(), "/.dillo/style.css", NULL); - FILE *fp = fopen (filename, "r"); if (fp) { - buf = (char*) dMalloc (100000); /* \todo proper buffer handling */ - fread (buf, 1, 100000, fp); - - a_Css_parse (this, buf, strlen (buf), 0, CSS_ORIGIN_USER); + Dstr *style = dStr_sized_new (1024); + size_t len; + + while ((len = fread (buf, 1, sizeof (buf), fp))) + dStr_append_l (style, buf, len); - dFree (buf); + a_Css_parse (this, style->str, style->len, 0, CSS_ORIGIN_USER); + dStr_free (style, 1); } dFree (filename); |