- }
-
- /* init FILE pointers */
- FL_end = 0;
- FileList[0] = stdout;
- for ( ; i < argc; i++) {
- /* add a file to FileList */
- file = fopen(argv[i], opt_fopen);
- if (!file) { continue; }
- if (FL_end < FL_MAX) {
- FileList[++FL_end] = file;
+
+ /* init FILE pointers */
+ FileList = calloc(FL_MAX, sizeof(FILE*));
+ if (!FileList) {
+ fprintf(stderr, "tee: %s\n", strerror(errno));
+ exit(1);
+ }
+ FL_end = 0;
+ FileList[0] = stdout;
+ for (; i < argc; i++) {
+ /* add a file to FileList */
+ file = fopen(argv[i], opt_fopen);
+ if (!file) {
+ continue;
+ }
+ if (FL_end < FL_MAX) {
+ FileList[++FL_end] = file;
+ }