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


apps/speed.c:2653:1: start of procedure do_multi()
2651.   }
2652.   
2653. > static int do_multi(int multi)
2654.   {
2655.       int n;

apps/speed.c:2658:5: 
2656.       int fd[2];
2657.       int *fds;
2658. >     static char sep[] = ":";
2659.   
2660.       fds = malloc(multi * sizeof *fds);

apps/speed.c:2660:5: 
2658.       static char sep[] = ":";
2659.   
2660. >     fds = malloc(multi * sizeof *fds);
2661.       for (n = 0; n < multi; ++n) {
2662.           if (pipe(fd) == -1) {

apps/speed.c:2661:10: 
2659.   
2660.       fds = malloc(multi * sizeof *fds);
2661. >     for (n = 0; n < multi; ++n) {
2662.           if (pipe(fd) == -1) {
2663.               fprintf(stderr, "pipe failure\n");

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

apps/speed.c:2662:13: Taking false branch
2660.       fds = malloc(multi * sizeof *fds);
2661.       for (n = 0; n < multi; ++n) {
2662.           if (pipe(fd) == -1) {
                    ^
2663.               fprintf(stderr, "pipe failure\n");
2664.               exit(1);

apps/speed.c:2666:9: 
2664.               exit(1);
2665.           }
2666. >         fflush(stdout);
2667.           fflush(stderr);
2668.           if (fork()) {

apps/speed.c:2667:9: 
2665.           }
2666.           fflush(stdout);
2667. >         fflush(stderr);
2668.           if (fork()) {
2669.               close(fd[1]);

apps/speed.c:2668:13: Taking true branch
2666.           fflush(stdout);
2667.           fflush(stderr);
2668.           if (fork()) {
                    ^
2669.               close(fd[1]);
2670.               fds[n] = fd[0];

apps/speed.c:2669:13: 
2667.           fflush(stderr);
2668.           if (fork()) {
2669. >             close(fd[1]);
2670.               fds[n] = fd[0];
2671.           } else {

apps/speed.c:2670:13: 
2668.           if (fork()) {
2669.               close(fd[1]);
2670. >             fds[n] = fd[0];
2671.           } else {
2672.               close(fd[0]);

apps/speed.c:2684:9: 
2682.               return 0;
2683.           }
2684. >         printf("Forked child %d\n", n);
2685.       }
2686.   

apps/speed.c:2661:28: 
2659.   
2660.       fds = malloc(multi * sizeof *fds);
2661. >     for (n = 0; n < multi; ++n) {
2662.           if (pipe(fd) == -1) {
2663.               fprintf(stderr, "pipe failure\n");

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

apps/speed.c:2662:13: Taking false branch
2660.       fds = malloc(multi * sizeof *fds);
2661.       for (n = 0; n < multi; ++n) {
2662.           if (pipe(fd) == -1) {
                    ^
2663.               fprintf(stderr, "pipe failure\n");
2664.               exit(1);

apps/speed.c:2666:9: 
2664.               exit(1);
2665.           }
2666. >         fflush(stdout);
2667.           fflush(stderr);
2668.           if (fork()) {

apps/speed.c:2667:9: 
2665.           }
2666.           fflush(stdout);
2667. >         fflush(stderr);
2668.           if (fork()) {
2669.               close(fd[1]);

apps/speed.c:2668:13: Taking true branch
2666.           fflush(stdout);
2667.           fflush(stderr);
2668.           if (fork()) {
                    ^
2669.               close(fd[1]);
2670.               fds[n] = fd[0];

apps/speed.c:2669:13: 
2667.           fflush(stderr);
2668.           if (fork()) {
2669. >             close(fd[1]);
2670.               fds[n] = fd[0];
2671.           } else {

apps/speed.c:2670:13: 
2668.           if (fork()) {
2669.               close(fd[1]);
2670. >             fds[n] = fd[0];
2671.           } else {
2672.               close(fd[0]);

apps/speed.c:2684:9: 
2682.               return 0;
2683.           }
2684. >         printf("Forked child %d\n", n);
2685.       }
2686.   

apps/speed.c:2661:28: 
2659.   
2660.       fds = malloc(multi * sizeof *fds);
2661. >     for (n = 0; n < multi; ++n) {
2662.           if (pipe(fd) == -1) {
2663.               fprintf(stderr, "pipe failure\n");

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

apps/speed.c:2662:13: Taking false branch
2660.       fds = malloc(multi * sizeof *fds);
2661.       for (n = 0; n < multi; ++n) {
2662.           if (pipe(fd) == -1) {
                    ^
2663.               fprintf(stderr, "pipe failure\n");
2664.               exit(1);

apps/speed.c:2666:9: 
2664.               exit(1);
2665.           }
2666. >         fflush(stdout);
2667.           fflush(stderr);
2668.           if (fork()) {

apps/speed.c:2667:9: 
2665.           }
2666.           fflush(stdout);
2667. >         fflush(stderr);
2668.           if (fork()) {
2669.               close(fd[1]);

apps/speed.c:2668:13: Taking true branch
2666.           fflush(stdout);
2667.           fflush(stderr);
2668.           if (fork()) {
                    ^
2669.               close(fd[1]);
2670.               fds[n] = fd[0];

apps/speed.c:2669:13: 
2667.           fflush(stderr);
2668.           if (fork()) {
2669. >             close(fd[1]);
2670.               fds[n] = fd[0];
2671.           } else {

apps/speed.c:2670:13: 
2668.           if (fork()) {
2669.               close(fd[1]);
2670. >             fds[n] = fd[0];
2671.           } else {
2672.               close(fd[0]);

apps/speed.c:2684:9: 
2682.               return 0;
2683.           }
2684. >         printf("Forked child %d\n", n);
2685.       }
2686.   

apps/speed.c:2661:28: 
2659.   
2660.       fds = malloc(multi * sizeof *fds);
2661. >     for (n = 0; n < multi; ++n) {
2662.           if (pipe(fd) == -1) {
2663.               fprintf(stderr, "pipe failure\n");

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

apps/speed.c:2688:10: 
2686.   
2687.       /* for now, assume the pipe is long enough to take all the output */
2688. >     for (n = 0; n < multi; ++n) {
2689.           FILE *f;
2690.           char buf[1024];

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

apps/speed.c:2693:9: 
2691.           char *p;
2692.   
2693. >         f = fdopen(fds[n], "r");
2694.           while (fgets(buf, sizeof buf, f)) {
2695.               p = strchr(buf, '\n');

apps/speed.c:2694:16: 
2692.   
2693.           f = fdopen(fds[n], "r");
2694. >         while (fgets(buf, sizeof buf, f)) {
2695.               p = strchr(buf, '\n');
2696.               if (p)
