commit: ff7b6b177b257cb59c6788c3216c5264255f6538
parent cc4d8780a1634f5c41084461eade02115b024c47
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 13 Sep 2024 23:19:24 +0200
cmd/tee: use calloc for arrays
Diffstat:
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/cmd/tee.c b/cmd/tee.c
@@ -7,7 +7,7 @@
#include <errno.h> /* errno */
#include <signal.h> /* signal() */
#include <stdio.h> /* fprintf(), fgetc(), fputc(), fclose(), fopen() */
-#include <stdlib.h> /* malloc(), free(), abort() */
+#include <stdlib.h> /* calloc(), free(), abort() */
#include <string.h> /* strerror() */
#include <unistd.h> /* getopt(), opt… */
@@ -45,8 +45,7 @@ main(int argc, char *argv[])
if(argc > 0)
{
- fds = malloc(sizeof(FILE *) * (size_t)argc);
-
+ fds = calloc(argc, sizeof(*fds));
if(!fds)
{
fprintf(stderr, "tee: Cannot allocate fd array: %s\n", strerror(errno));