ref: d05befa132d71d46f30781497dfdf04ba23f2359
parent: b6029c2fc4e92d99239ab1cfec921a717d0aca95
author: cinap_lenrek <cinap_lenrek@localhost>
date: Mon Aug 22 20:23:00 EDT 2011
paqfs: fix potential freeing of non heap string
--- a/sys/src/cmd/paqfs/paqfs.c
+++ b/sys/src/cmd/paqfs/paqfs.c
@@ -72,7 +72,6 @@
Fid * newfid(int);
void paqstat(PaqDir*, char*);
void io(int fd);
-void *erealloc(void*, ulong);
void *emalloc(ulong);
void *emallocz(ulong n);
char *estrdup(char*);
@@ -300,7 +299,7 @@
if(rhdr.uname[0])
f->user = estrdup(rhdr.uname);
else
- f->user = "none";
+ f->user = estrdup("none");return 0;
}
@@ -317,7 +316,7 @@
nf->busy = 1;
nf->open = 0;
nf->paq = paqCpy(f->paq);
- nf->user = strdup(f->user);
+ nf->user = estrdup(f->user);
*res = nf;
return 0;
}
@@ -570,7 +569,9 @@
f->busy = 0;
f->open = 0;
free(f->user);
+ f->user = 0;
paqFree(f->paq);
+ f->paq = 0;
return 0;
}
@@ -1075,15 +1076,6 @@
p = emalloc(n);
memset(p, 0, n);
- return p;
-}
-
-void *
-erealloc(void *p, ulong n)
-{- p = realloc(p, n);
- if(!p)
- sysfatal("out of memory");return p;
}
--
⑨