apps/speed.c:2582: error: NULL_DEREFERENCE
  pointer `f` last assigned on line 2581 could be null and is dereferenced by call to `fgets()` at line 2582, column 16.
Showing all 36 steps of the trace


apps/speed.c:2541:1: start of procedure do_multi()
2539.   }
2540.   
2541. > static int do_multi(int multi)
2542.   {
2543.       int n;

apps/speed.c:2546:5: 
2544.       int fd[2];
2545.       int *fds;
2546. >     static char sep[] = ":";
2547.   
2548.       fds = malloc(multi * sizeof *fds);

apps/speed.c:2548:5: 
2546.       static char sep[] = ":";
2547.   
2548. >     fds = malloc(multi * sizeof *fds);
2549.       for (n = 0; n < multi; ++n) {
2550.           if (pipe(fd) == -1) {

apps/speed.c:2549:10: 
2547.   
2548.       fds = malloc(multi * sizeof *fds);
2549. >     for (n = 0; n < multi; ++n) {
2550.           if (pipe(fd) == -1) {
2551.               fprintf(stderr, "pipe failure\n");

apps/speed.c:2549:17: Loop condition is true. Entering loop body
2547.   
2548.       fds = malloc(multi * sizeof *fds);
2549.       for (n = 0; n < multi; ++n) {
                        ^
2550.           if (pipe(fd) == -1) {
2551.               fprintf(stderr, "pipe failure\n");

apps/speed.c:2550:13: Taking false branch
2548.       fds = malloc(multi * sizeof *fds);
2549.       for (n = 0; n < multi; ++n) {
2550.           if (pipe(fd) == -1) {
                    ^
2551.               fprintf(stderr, "pipe failure\n");
2552.               exit(1);

apps/speed.c:2554:9: 
2552.               exit(1);
2553.           }
2554. >         fflush(stdout);
2555.           fflush(stderr);
2556.           if (fork()) {

apps/speed.c:2555:9: 
2553.           }
2554.           fflush(stdout);
2555. >         fflush(stderr);
2556.           if (fork()) {
2557.               close(fd[1]);

apps/speed.c:2556:13: Taking true branch
2554.           fflush(stdout);
2555.           fflush(stderr);
2556.           if (fork()) {
                    ^
2557.               close(fd[1]);
2558.               fds[n] = fd[0];

apps/speed.c:2557:13: 
2555.           fflush(stderr);
2556.           if (fork()) {
2557. >             close(fd[1]);
2558.               fds[n] = fd[0];
2559.           } else {

apps/speed.c:2558:13: 
2556.           if (fork()) {
2557.               close(fd[1]);
2558. >             fds[n] = fd[0];
2559.           } else {
2560.               close(fd[0]);

apps/speed.c:2572:9: 
2570.               return 0;
2571.           }
2572. >         printf("Forked child %d\n", n);
2573.       }
2574.   

apps/speed.c:2549:28: 
2547.   
2548.       fds = malloc(multi * sizeof *fds);
2549. >     for (n = 0; n < multi; ++n) {
2550.           if (pipe(fd) == -1) {
2551.               fprintf(stderr, "pipe failure\n");

apps/speed.c:2549:17: Loop condition is true. Entering loop body
2547.   
2548.       fds = malloc(multi * sizeof *fds);
2549.       for (n = 0; n < multi; ++n) {
                        ^
2550.           if (pipe(fd) == -1) {
2551.               fprintf(stderr, "pipe failure\n");

apps/speed.c:2550:13: Taking false branch
2548.       fds = malloc(multi * sizeof *fds);
2549.       for (n = 0; n < multi; ++n) {
2550.           if (pipe(fd) == -1) {
                    ^
2551.               fprintf(stderr, "pipe failure\n");
2552.               exit(1);

apps/speed.c:2554:9: 
2552.               exit(1);
2553.           }
2554. >         fflush(stdout);
2555.           fflush(stderr);
2556.           if (fork()) {

apps/speed.c:2555:9: 
2553.           }
2554.           fflush(stdout);
2555. >         fflush(stderr);
2556.           if (fork()) {
2557.               close(fd[1]);

apps/speed.c:2556:13: Taking true branch
2554.           fflush(stdout);
2555.           fflush(stderr);
2556.           if (fork()) {
                    ^
2557.               close(fd[1]);
2558.               fds[n] = fd[0];

apps/speed.c:2557:13: 
2555.           fflush(stderr);
2556.           if (fork()) {
2557. >             close(fd[1]);
2558.               fds[n] = fd[0];
2559.           } else {

apps/speed.c:2558:13: 
2556.           if (fork()) {
2557.               close(fd[1]);
2558. >             fds[n] = fd[0];
2559.           } else {
2560.               close(fd[0]);

apps/speed.c:2572:9: 
2570.               return 0;
2571.           }
2572. >         printf("Forked child %d\n", n);
2573.       }
2574.   

apps/speed.c:2549:28: 
2547.   
2548.       fds = malloc(multi * sizeof *fds);
2549. >     for (n = 0; n < multi; ++n) {
2550.           if (pipe(fd) == -1) {
2551.               fprintf(stderr, "pipe failure\n");

apps/speed.c:2549:17: Loop condition is true. Entering loop body
2547.   
2548.       fds = malloc(multi * sizeof *fds);
2549.       for (n = 0; n < multi; ++n) {
                        ^
2550.           if (pipe(fd) == -1) {
2551.               fprintf(stderr, "pipe failure\n");

apps/speed.c:2550:13: Taking false branch
2548.       fds = malloc(multi * sizeof *fds);
2549.       for (n = 0; n < multi; ++n) {
2550.           if (pipe(fd) == -1) {
                    ^
2551.               fprintf(stderr, "pipe failure\n");
2552.               exit(1);

apps/speed.c:2554:9: 
2552.               exit(1);
2553.           }
2554. >         fflush(stdout);
2555.           fflush(stderr);
2556.           if (fork()) {

apps/speed.c:2555:9: 
2553.           }
2554.           fflush(stdout);
2555. >         fflush(stderr);
2556.           if (fork()) {
2557.               close(fd[1]);

apps/speed.c:2556:13: Taking true branch
2554.           fflush(stdout);
2555.           fflush(stderr);
2556.           if (fork()) {
                    ^
2557.               close(fd[1]);
2558.               fds[n] = fd[0];

apps/speed.c:2557:13: 
2555.           fflush(stderr);
2556.           if (fork()) {
2557. >             close(fd[1]);
2558.               fds[n] = fd[0];
2559.           } else {

apps/speed.c:2558:13: 
2556.           if (fork()) {
2557.               close(fd[1]);
2558. >             fds[n] = fd[0];
2559.           } else {
2560.               close(fd[0]);

apps/speed.c:2572:9: 
2570.               return 0;
2571.           }
2572. >         printf("Forked child %d\n", n);
2573.       }
2574.   

apps/speed.c:2549:28: 
2547.   
2548.       fds = malloc(multi * sizeof *fds);
2549. >     for (n = 0; n < multi; ++n) {
2550.           if (pipe(fd) == -1) {
2551.               fprintf(stderr, "pipe failure\n");

apps/speed.c:2549:17: Loop condition is false. Leaving loop
2547.   
2548.       fds = malloc(multi * sizeof *fds);
2549.       for (n = 0; n < multi; ++n) {
                        ^
2550.           if (pipe(fd) == -1) {
2551.               fprintf(stderr, "pipe failure\n");

apps/speed.c:2576:10: 
2574.   
2575.       /* for now, assume the pipe is long enough to take all the output */
2576. >     for (n = 0; n < multi; ++n) {
2577.           FILE *f;
2578.           char buf[1024];

apps/speed.c:2576:17: Loop condition is true. Entering loop body
2574.   
2575.       /* for now, assume the pipe is long enough to take all the output */
2576.       for (n = 0; n < multi; ++n) {
                        ^
2577.           FILE *f;
2578.           char buf[1024];

apps/speed.c:2581:9: 
2579.           char *p;
2580.   
2581. >         f = fdopen(fds[n], "r");
2582.           while (fgets(buf, sizeof buf, f)) {
2583.               p = strchr(buf, '\n');

apps/speed.c:2582:16: 
2580.   
2581.           f = fdopen(fds[n], "r");
2582. >         while (fgets(buf, sizeof buf, f)) {
2583.               p = strchr(buf, '\n');
2584.               if (p)
