Introduction
Introduction Statistics Contact Development Disclaimer Help
don't exit on failed initialization (would crash the page) - surf-adblock - Sur…
git clone git://git.codemadness.org/surf-adblock
Log
Files
Refs
README
LICENSE
---
commit 1b2fa25986e2fbbecc4caa7a220364536fdab2af
parent c08593ce08d4b64713b3d8dd5433e9226d9df018
Author: Hiltjo Posthuma <[email protected]>
Date: Sun, 17 Jul 2016 14:07:23 +0200
don't exit on failed initialization (would crash the page)
we still have to think how to handle OOM situations.
Diffstat:
M surf-adblock.c | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/surf-adblock.c b/surf-adblock.c
@@ -112,6 +112,18 @@ static String globalcss;
static struct filterrule *rules;
static void
+weprintf(const char *fmt, ...)
+{
+ va_list ap;
+
+ fprintf(stderr, "surf-adblock: ");
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
+static void
eprintf(const char *fmt, ...)
{
va_list ap;
@@ -827,15 +839,21 @@ webkit_web_extension_initialize(WebKitWebExtension *ext)
n = snprintf(filepath, sizeof(filepath),
"%s%s.surf/adblockrules", e, e[0] ? "/" : "");
}
- if (n < 0 || (size_t)n >= sizeof(filepath))
- eprintf("fatal: rules file path too long");
+ if (n < 0 || (size_t)n >= sizeof(filepath)) {
+ weprintf("fatal: rules file path too long");
+ return;
+ }
- if (!(fp = fopen(filepath, "r")))
- eprintf("fatal: cannot open rules file %s: %s\n",
+ if (!(fp = fopen(filepath, "r"))) {
+ weprintf("fatal: cannot open rules file %s: %s\n",
filepath, strerror(errno));
- if (!(rules = loadrules(fp)))
- eprintf("fatal: cannot read rules file %s: %s\n",
+ return;
+ }
+ if (!(rules = loadrules(fp))) {
+ weprintf("fatal: cannot read rules file %s: %s\n",
filepath, strerror(errno));
+ return;
+ }
fclose(fp);
/* general CSS rules: all sites */
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.