Introduction
Introduction Statistics Contact Development Disclaimer Help
cleanup on global css rules parsing error - surf-adblock - Surf adblock web ext…
git clone git://git.codemadness.org/surf-adblock
Log
Files
Refs
README
LICENSE
---
commit ab4d1e8f7ed4eafd6d1a7a99bc183944c1dc7e41
parent 08fb7a7ce1e8ac16f40f72820b3122bcc30c2100
Author: Quentin Rameau <[email protected]>
Date: Sun, 17 Jul 2016 20:53:50 +0200
cleanup on global css rules parsing error
All possible errors there would have occurred before binding to the
webkit signals so we just need to free allocated memory and return.
Diffstat:
M surf-adblock.c | 38 ++++++++++++++++++++++++++++-…
1 file changed, 35 insertions(+), 3 deletions(-)
---
diff --git a/surf-adblock.c b/surf-adblock.c
@@ -112,6 +112,27 @@ static Page *pages;
static struct filterrule *rules;
static void
+cleanup(void)
+{
+ struct filterrule *r;
+ struct filterdomain *d;
+
+ free(globalcss.data);
+
+ for (r = rules; r; r = rules) {
+ for (d = r->domains; d; d = r->domains) {
+ free(d->domain);
+ r->domains = d->next;
+ free(d);
+ }
+ free(r->css);
+ free(r->uri);
+ rules = r->next;
+ free(r);
+ }
+}
+
+static void
weprintf(const char *fmt, ...)
{
va_list ap;
@@ -835,8 +856,11 @@ webpagecreated(WebKitWebExtension *e, WebKitWebPage *p, gp…
{
Page *np;
- if (!(np = newpage(p)))
+ if (!(np = newpage(p))) {
+ weprintf("cannot associate webext with new page: %s\n",
+ strerror(errno));
return;
+ }
g_signal_connect(p, "document-loaded", G_CALLBACK(documentloaded), np);
g_signal_connect(p, "send-request", G_CALLBACK(sendrequest), np);
@@ -889,11 +913,19 @@ webkit_web_extension_initialize(WebKitWebExtension *ext)
continue;
len = strlen(r->css);
- if (string_append(&globalcss, r->css, strlen(r->css)) < len)
+ if (string_append(&globalcss, r->css, strlen(r->css)) < len) {
+ weprintf("cannot load global css selectors "
+ "in memory\n");
+ cleanup();
return;
+ }
len = sizeof("{display:none;}") - 1;
- if (string_append(&globalcss, "{display:none;}", len) < len)
+ if (string_append(&globalcss, "{display:none;}", len) < len) {
+ weprintf("cannot append css rule "
+ "to global css selectors\n");
+ cleanup();
return;
+ }
}
g_signal_connect(ext, "page-created", G_CALLBACK(webpagecreated), NULL…
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.