devdraw, libdraw: fix memory leaks by freeing getns() malloced string (#431)
This commit is contained in:
parent
057d8a76a9
commit
afa34a73a9
2 changed files with 11 additions and 4 deletions
|
|
@ -88,7 +88,7 @@ threadmain(int argc, char **argv)
|
||||||
void
|
void
|
||||||
gfx_started(void)
|
gfx_started(void)
|
||||||
{
|
{
|
||||||
char *addr;
|
char *ns, *addr;
|
||||||
|
|
||||||
if(srvname == nil) {
|
if(srvname == nil) {
|
||||||
// Legacy mode: serving single client on pipes.
|
// Legacy mode: serving single client on pipes.
|
||||||
|
|
@ -97,7 +97,11 @@ gfx_started(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server mode.
|
// Server mode.
|
||||||
addr = smprint("unix!%s/%s", getns(), srvname);
|
if((ns = getns()) == nil)
|
||||||
|
sysfatal("out of memory");
|
||||||
|
|
||||||
|
addr = smprint("unix!%s/%s", ns, srvname);
|
||||||
|
free(ns);
|
||||||
if(addr == nil)
|
if(addr == nil)
|
||||||
sysfatal("out of memory");
|
sysfatal("out of memory");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ int
|
||||||
_displayconnect(Display *d)
|
_displayconnect(Display *d)
|
||||||
{
|
{
|
||||||
int pid, p[2], fd, nbuf, n;
|
int pid, p[2], fd, nbuf, n;
|
||||||
char *wsysid, *addr, *id;
|
char *wsysid, *ns, *addr, *id;
|
||||||
uchar *buf;
|
uchar *buf;
|
||||||
Wsysmsg w;
|
Wsysmsg w;
|
||||||
|
|
||||||
|
|
@ -40,7 +40,10 @@ _displayconnect(Display *d)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*id++ = '\0';
|
*id++ = '\0';
|
||||||
addr = smprint("unix!%s/%s", getns(), wsysid);
|
if((ns = getns()) == nil)
|
||||||
|
return -1;
|
||||||
|
addr = smprint("unix!%s/%s", ns, wsysid);
|
||||||
|
free(ns);
|
||||||
if(addr == nil)
|
if(addr == nil)
|
||||||
return -1;
|
return -1;
|
||||||
fd = dial(addr, 0, 0, 0);
|
fd = dial(addr, 0, 0, 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue