faces: fix memory leaks

This commit is contained in:
cinap_lenrek 2012-04-30 11:48:30 +02:00
parent a124609b6e
commit 748bdc13b2
2 changed files with 14 additions and 3 deletions

View file

@ -270,8 +270,10 @@ tryfindfiledir(char *dom, char *user, char *dir)
* Ignore 512x512 directories.
* Save 48x48 directories for later.
*/
if((fd = open(dir, OREAD)) < 0)
if((fd = open(dir, OREAD)) < 0){
free(dom);
return nil;
}
while((n = dirread(fd, &d)) > 0){
for(i=0; i<n; i++){
if((d[i].mode&DMDIR)
@ -288,6 +290,7 @@ tryfindfiledir(char *dom, char *user, char *dir)
free(dom);
return x;
}
free(ndir);
}
}
free(d);
@ -340,8 +343,12 @@ findfile(Face *f, char *dom, char *user)
}
if(dom == nil)
dom = facedom;
if(homeface == nil)
homeface = smprint("%s/lib/face", getenv("home"));
if(homeface == nil){
if((p = getenv("home")) != nil){
homeface = smprint("%s/lib/face", p);
free(p);
}
}
f->unknown = 0;
if((p = tryfindfile(dom, user)) != nil)
@ -575,4 +582,5 @@ findbit(Face *f)
replclipr(f->bit, 1, Rect(0, 0, Facesize, Facesize));
f->mask = nil;
}
free(fn);
}

View file

@ -14,6 +14,7 @@ emalloc(ulong sz)
exits("mem");
}
memset(v, 0, sz);
setmalloctag(v, getcallerpc(&sz));
return v;
}
@ -25,6 +26,7 @@ erealloc(void *v, ulong sz)
fprint(2, "out of memory allocating %ld\n", sz);
exits("mem");
}
setrealloctag(v, getcallerpc(&sz));
return v;
}
@ -36,6 +38,7 @@ estrdup(char *s)
fprint(2, "out of memory in strdup(%.10s)\n", s);
exits("mem");
}
setmalloctag(t, getcallerpc(&s));
return t;
}