Fixed some memory leaks in namesys/dns and path/path

This commit is contained in:
Jose Marcial Vieira Bisneto 2016-11-29 08:26:05 -03:00
parent 74a5afe169
commit 47e035e29f
2 changed files with 9 additions and 8 deletions

View file

@ -68,13 +68,6 @@ int DNSResolverResolveOnce (char **path, char *name)
return ErrPipe;
}
dnslink = malloc(strlen(domain) + sizeof(dlprefix));
if (!dnslink) {
return ErrAllocFailed;
}
strcpy (dnslink, dlprefix);
strcat (dnslink, domain);
r = fork();
switch(r) {
case -1:
@ -90,6 +83,14 @@ int DNSResolverResolveOnce (char **path, char *name)
return ErrPipe;
case 0: // child
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);
}
close(p2[STDOUT_FILENO]); // we don't need to write at main process.

View file

@ -43,7 +43,7 @@ char** SplitN (char *p, char *delim, int n)
r = calloc(sizeof(char*), n + 1); // splits plus NULL pointer termination
if (!r) {
free(r);
free(rbuf);
return NULL;
}