ref: 2bba1846b3ca24fd6847bcb036fdb441113110e5
parent: 0a698326b540f478c1c05b304236f3f7a41ed661
author: cinap_lenrek <cinap_lenrek@rei2.9hal>
date: Thu Dec 29 12:56:28 EST 2011
webcookies: fix memory leak, remove fragment from url
--- a/sys/src/cmd/webcookies.c
+++ b/sys/src/cmd/webcookies.c
@@ -407,7 +407,7 @@
purgejar(jar);
- b = Bopen(jar->file, OWRITE);
+ b = Bopen(jar->file, OTRUNC|OWRITE);
if(b == nil){if(debug)
fprint(2, "Bopen write %s: %r", jar->file);
@@ -467,6 +467,8 @@
{int i;
+ if(jar == nil)
+ return;
expirejar(jar, 0);
if(syncjar(jar) < 0)
fprint(2, "warning: cannot rewrite cookie jar: %r\n");
@@ -475,6 +477,7 @@
freecookie(&jar->c[i]);
free(jar->file);
+ free(jar->c);
free(jar);
}
@@ -948,6 +951,7 @@
if(cistrcmp(attr, "secure") == 0)
c->secure = 1;
}
+ *e = p;
if(c->dom)
c->explicitdom = 1;
@@ -957,6 +961,8 @@
c->explicitpath = 1;
else{c->path = path;
+ if((t = strchr(c->path, '#')) != 0)
+ *t = '\0';
if((t = strchr(c->path, '?')) != 0)
*t = '\0';
if((t = strrchr(c->path, '/')) != 0)
@@ -963,7 +969,6 @@
*t = '\0';
}
c->netscapestyle = isns;
- *e = p;
return nil;
}
--
⑨