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


apps/speed.c:2586:1: start of procedure do_multi()
2584.   }
2585.   
2586. > static int do_multi(int multi)
2587.   {
2588.       int n;

apps/speed.c:2591:5: 
2589.       int fd[2];
2590.       int *fds;
2591. >     static char sep[] = ":";
2592.   
2593.       fds = malloc(multi * sizeof *fds);

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

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

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

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

apps/speed.c:2599:9: 
2597.               exit(1);
2598.           }
2599. >         fflush(stdout);
2600.           fflush(stderr);
2601.           if (fork()) {

apps/speed.c:2600:9: 
2598.           }
2599.           fflush(stdout);
2600. >         fflush(stderr);
2601.           if (fork()) {
2602.               close(fd[1]);

apps/speed.c:2601:13: Taking true branch
2599.           fflush(stdout);
2600.           fflush(stderr);
2601.           if (fork()) {
                    ^
2602.               close(fd[1]);
2603.               fds[n] = fd[0];

apps/speed.c:2602:13: 
2600.           fflush(stderr);
2601.           if (fork()) {
2602. >             close(fd[1]);
2603.               fds[n] = fd[0];
2604.           } else {

apps/speed.c:2603:13: 
2601.           if (fork()) {
2602.               close(fd[1]);
2603. >             fds[n] = fd[0];
2604.           } else {
2605.               close(fd[0]);

apps/speed.c:2617:9: 
2615.               return 0;
2616.           }
2617. >         printf("Forked child %d\n", n);
2618.       }
2619.   

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

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

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

apps/speed.c:2599:9: 
2597.               exit(1);
2598.           }
2599. >         fflush(stdout);
2600.           fflush(stderr);
2601.           if (fork()) {

apps/speed.c:2600:9: 
2598.           }
2599.           fflush(stdout);
2600. >         fflush(stderr);
2601.           if (fork()) {
2602.               close(fd[1]);

apps/speed.c:2601:13: Taking true branch
2599.           fflush(stdout);
2600.           fflush(stderr);
2601.           if (fork()) {
                    ^
2602.               close(fd[1]);
2603.               fds[n] = fd[0];

apps/speed.c:2602:13: 
2600.           fflush(stderr);
2601.           if (fork()) {
2602. >             close(fd[1]);
2603.               fds[n] = fd[0];
2604.           } else {

apps/speed.c:2603:13: 
2601.           if (fork()) {
2602.               close(fd[1]);
2603. >             fds[n] = fd[0];
2604.           } else {
2605.               close(fd[0]);

apps/speed.c:2617:9: 
2615.               return 0;
2616.           }
2617. >         printf("Forked child %d\n", n);
2618.       }
2619.   

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

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

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

apps/speed.c:2599:9: 
2597.               exit(1);
2598.           }
2599. >         fflush(stdout);
2600.           fflush(stderr);
2601.           if (fork()) {

apps/speed.c:2600:9: 
2598.           }
2599.           fflush(stdout);
2600. >         fflush(stderr);
2601.           if (fork()) {
2602.               close(fd[1]);

apps/speed.c:2601:13: Taking true branch
2599.           fflush(stdout);
2600.           fflush(stderr);
2601.           if (fork()) {
                    ^
2602.               close(fd[1]);
2603.               fds[n] = fd[0];

apps/speed.c:2602:13: 
2600.           fflush(stderr);
2601.           if (fork()) {
2602. >             close(fd[1]);
2603.               fds[n] = fd[0];
2604.           } else {

apps/speed.c:2603:13: 
2601.           if (fork()) {
2602.               close(fd[1]);
2603. >             fds[n] = fd[0];
2604.           } else {
2605.               close(fd[0]);

apps/speed.c:2617:9: 
2615.               return 0;
2616.           }
2617. >         printf("Forked child %d\n", n);
2618.       }
2619.   

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

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

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

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

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

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