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


apps/speed.c:2544:1: start of procedure do_multi()
2542.   }
2543.   
2544. > static int do_multi(int multi)
2545.   {
2546.       int n;

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

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

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

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

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

apps/speed.c:2557:9: 
2555.               exit(1);
2556.           }
2557. >         fflush(stdout);
2558.           fflush(stderr);
2559.           if (fork()) {

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

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

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

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

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

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

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

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

apps/speed.c:2557:9: 
2555.               exit(1);
2556.           }
2557. >         fflush(stdout);
2558.           fflush(stderr);
2559.           if (fork()) {

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

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

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

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

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

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

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

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

apps/speed.c:2557:9: 
2555.               exit(1);
2556.           }
2557. >         fflush(stdout);
2558.           fflush(stderr);
2559.           if (fork()) {

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

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

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

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

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

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

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

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

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

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

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