Fixed some memory leaks in namesys/dns and path/path
This commit is contained in:
parent
74a5afe169
commit
47e035e29f
2 changed files with 9 additions and 8 deletions
|
@ -68,13 +68,6 @@ int DNSResolverResolveOnce (char **path, char *name)
|
||||||
return ErrPipe;
|
return ErrPipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
dnslink = malloc(strlen(domain) + sizeof(dlprefix));
|
|
||||||
if (!dnslink) {
|
|
||||||
return ErrAllocFailed;
|
|
||||||
}
|
|
||||||
strcpy (dnslink, dlprefix);
|
|
||||||
strcat (dnslink, domain);
|
|
||||||
|
|
||||||
r = fork();
|
r = fork();
|
||||||
switch(r) {
|
switch(r) {
|
||||||
case -1:
|
case -1:
|
||||||
|
@ -90,6 +83,14 @@ int DNSResolverResolveOnce (char **path, char *name)
|
||||||
return ErrPipe;
|
return ErrPipe;
|
||||||
case 0: // child
|
case 0: // child
|
||||||
close(p2[STDIN_FILENO]); // we don't need to read at child process.
|
close(p2[STDIN_FILENO]); // we don't need to read at child process.
|
||||||
|
|
||||||
|
dnslink = malloc(strlen(domain) + sizeof(dlprefix));
|
||||||
|
if (!dnslink) {
|
||||||
|
return ErrAllocFailed;
|
||||||
|
}
|
||||||
|
strcpy (dnslink, dlprefix);
|
||||||
|
strcat (dnslink, domain);
|
||||||
|
|
||||||
return workDomain (p2[STDOUT_FILENO], r, dnslink);
|
return workDomain (p2[STDOUT_FILENO], r, dnslink);
|
||||||
}
|
}
|
||||||
close(p2[STDOUT_FILENO]); // we don't need to write at main process.
|
close(p2[STDOUT_FILENO]); // we don't need to write at main process.
|
||||||
|
|
|
@ -43,7 +43,7 @@ char** SplitN (char *p, char *delim, int n)
|
||||||
|
|
||||||
r = calloc(sizeof(char*), n + 1); // splits plus NULL pointer termination
|
r = calloc(sizeof(char*), n + 1); // splits plus NULL pointer termination
|
||||||
if (!r) {
|
if (!r) {
|
||||||
free(r);
|
free(rbuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue