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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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