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


apps/speed.c:2582:1: start of procedure do_multi()
2580.   }
2581.   
2582. > static int do_multi(int multi)
2583.   {
2584.       int n;

apps/speed.c:2587:5: 
2585.       int fd[2];
2586.       int *fds;
2587. >     static char sep[] = ":";
2588.   
2589.       fds = malloc(multi * sizeof *fds);

apps/speed.c:2589:5: 
2587.       static char sep[] = ":";
2588.   
2589. >     fds = malloc(multi * sizeof *fds);
2590.       for (n = 0; n < multi; ++n) {
2591.           if (pipe(fd) == -1) {

apps/speed.c:2590:10: 
2588.   
2589.       fds = malloc(multi * sizeof *fds);
2590. >     for (n = 0; n < multi; ++n) {
2591.           if (pipe(fd) == -1) {
2592.               fprintf(stderr, "pipe failure\n");

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

apps/speed.c:2591:13: Taking false branch
2589.       fds = malloc(multi * sizeof *fds);
2590.       for (n = 0; n < multi; ++n) {
2591.           if (pipe(fd) == -1) {
                    ^
2592.               fprintf(stderr, "pipe failure\n");
2593.               exit(1);

apps/speed.c:2595:9: 
2593.               exit(1);
2594.           }
2595. >         fflush(stdout);
2596.           fflush(stderr);
2597.           if (fork()) {

apps/speed.c:2596:9: 
2594.           }
2595.           fflush(stdout);
2596. >         fflush(stderr);
2597.           if (fork()) {
2598.               close(fd[1]);

apps/speed.c:2597:13: Taking true branch
2595.           fflush(stdout);
2596.           fflush(stderr);
2597.           if (fork()) {
                    ^
2598.               close(fd[1]);
2599.               fds[n] = fd[0];

apps/speed.c:2598:13: 
2596.           fflush(stderr);
2597.           if (fork()) {
2598. >             close(fd[1]);
2599.               fds[n] = fd[0];
2600.           } else {

apps/speed.c:2599:13: 
2597.           if (fork()) {
2598.               close(fd[1]);
2599. >             fds[n] = fd[0];
2600.           } else {
2601.               close(fd[0]);

apps/speed.c:2613:9: 
2611.               return 0;
2612.           }
2613. >         printf("Forked child %d\n", n);
2614.       }
2615.   

apps/speed.c:2590:28: 
2588.   
2589.       fds = malloc(multi * sizeof *fds);
2590. >     for (n = 0; n < multi; ++n) {
2591.           if (pipe(fd) == -1) {
2592.               fprintf(stderr, "pipe failure\n");

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

apps/speed.c:2591:13: Taking false branch
2589.       fds = malloc(multi * sizeof *fds);
2590.       for (n = 0; n < multi; ++n) {
2591.           if (pipe(fd) == -1) {
                    ^
2592.               fprintf(stderr, "pipe failure\n");
2593.               exit(1);

apps/speed.c:2595:9: 
2593.               exit(1);
2594.           }
2595. >         fflush(stdout);
2596.           fflush(stderr);
2597.           if (fork()) {

apps/speed.c:2596:9: 
2594.           }
2595.           fflush(stdout);
2596. >         fflush(stderr);
2597.           if (fork()) {
2598.               close(fd[1]);

apps/speed.c:2597:13: Taking true branch
2595.           fflush(stdout);
2596.           fflush(stderr);
2597.           if (fork()) {
                    ^
2598.               close(fd[1]);
2599.               fds[n] = fd[0];

apps/speed.c:2598:13: 
2596.           fflush(stderr);
2597.           if (fork()) {
2598. >             close(fd[1]);
2599.               fds[n] = fd[0];
2600.           } else {

apps/speed.c:2599:13: 
2597.           if (fork()) {
2598.               close(fd[1]);
2599. >             fds[n] = fd[0];
2600.           } else {
2601.               close(fd[0]);

apps/speed.c:2613:9: 
2611.               return 0;
2612.           }
2613. >         printf("Forked child %d\n", n);
2614.       }
2615.   

apps/speed.c:2590:28: 
2588.   
2589.       fds = malloc(multi * sizeof *fds);
2590. >     for (n = 0; n < multi; ++n) {
2591.           if (pipe(fd) == -1) {
2592.               fprintf(stderr, "pipe failure\n");

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

apps/speed.c:2591:13: Taking false branch
2589.       fds = malloc(multi * sizeof *fds);
2590.       for (n = 0; n < multi; ++n) {
2591.           if (pipe(fd) == -1) {
                    ^
2592.               fprintf(stderr, "pipe failure\n");
2593.               exit(1);

apps/speed.c:2595:9: 
2593.               exit(1);
2594.           }
2595. >         fflush(stdout);
2596.           fflush(stderr);
2597.           if (fork()) {

apps/speed.c:2596:9: 
2594.           }
2595.           fflush(stdout);
2596. >         fflush(stderr);
2597.           if (fork()) {
2598.               close(fd[1]);

apps/speed.c:2597:13: Taking true branch
2595.           fflush(stdout);
2596.           fflush(stderr);
2597.           if (fork()) {
                    ^
2598.               close(fd[1]);
2599.               fds[n] = fd[0];

apps/speed.c:2598:13: 
2596.           fflush(stderr);
2597.           if (fork()) {
2598. >             close(fd[1]);
2599.               fds[n] = fd[0];
2600.           } else {

apps/speed.c:2599:13: 
2597.           if (fork()) {
2598.               close(fd[1]);
2599. >             fds[n] = fd[0];
2600.           } else {
2601.               close(fd[0]);

apps/speed.c:2613:9: 
2611.               return 0;
2612.           }
2613. >         printf("Forked child %d\n", n);
2614.       }
2615.   

apps/speed.c:2590:28: 
2588.   
2589.       fds = malloc(multi * sizeof *fds);
2590. >     for (n = 0; n < multi; ++n) {
2591.           if (pipe(fd) == -1) {
2592.               fprintf(stderr, "pipe failure\n");

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

apps/speed.c:2617:10: 
2615.   
2616.       /* for now, assume the pipe is long enough to take all the output */
2617. >     for (n = 0; n < multi; ++n) {
2618.           FILE *f;
2619.           char buf[1024];

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

apps/speed.c:2622:9: 
2620.           char *p;
2621.   
2622. >         f = fdopen(fds[n], "r");
2623.           while (fgets(buf, sizeof buf, f)) {
2624.               p = strchr(buf, '\n');

apps/speed.c:2623:16: 
2621.   
2622.           f = fdopen(fds[n], "r");
2623. >         while (fgets(buf, sizeof buf, f)) {
2624.               p = strchr(buf, '\n');
2625.               if (p)
