diff options
author | pfg <pfg@FreeBSD.org> | 2016-04-18 15:01:49 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2016-04-18 15:01:49 +0000 |
commit | ae9a652080bc3b428fd4d797c6329b05e1018366 (patch) | |
tree | a49a9fc353a8f0d73fa6fd3837609dffdcca4862 | |
parent | 69f0978333674cf5ecc98045212b50a953d294ae (diff) | |
download | FreeBSD-src-ae9a652080bc3b428fd4d797c6329b05e1018366.zip FreeBSD-src-ae9a652080bc3b428fd4d797c6329b05e1018366.tar.gz |
ftpd: replace malloc + memset 0 with calloc.
It is faster and usually safer.
Use NULL instead of zero for the pointer.
-rw-r--r-- | libexec/ftpd/popen.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libexec/ftpd/popen.c b/libexec/ftpd/popen.c index 03b8f7a..5620a79 100644 --- a/libexec/ftpd/popen.c +++ b/libexec/ftpd/popen.c @@ -81,9 +81,8 @@ ftpd_popen(char *program, char *type) if (!pids) { if ((fds = getdtablesize()) <= 0) return (NULL); - if ((pids = malloc(fds * sizeof(int))) == NULL) + if ((pids = calloc(fds, sizeof(int))) == NULL) return (NULL); - memset(pids, 0, fds * sizeof(int)); } if (pipe(pdes) < 0) return (NULL); @@ -185,7 +184,7 @@ ftpd_pclose(FILE *iop) * pclose returns -1 if stream is not associated with a * `popened' command, or, if already `pclosed'. */ - if (pids == 0 || pids[fdes = fileno(iop)] == 0) + if (pids == NULL || pids[fdes = fileno(iop)] == 0) return (-1); (void)fclose(iop); omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP)); |