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 9.
Showing all 36 steps of the trace


apps/speed.c:2646:1: start of procedure do_multi()
2644.       }
2645.   
2646. > static int do_multi(int multi)
2647.   	{
2648.   	int n;

apps/speed.c:2651:2: 
2649.   	int fd[2];
2650.   	int *fds;
2651. > 	static char sep[]=":";
2652.   
2653.   	fds=malloc(multi*sizeof *fds);

apps/speed.c:2653:2: 
2651.   	static char sep[]=":";
2652.   
2653. > 	fds=malloc(multi*sizeof *fds);
2654.   	for(n=0 ; n < multi ; ++n)
2655.   		{

apps/speed.c:2654:6: 
2652.   
2653.   	fds=malloc(multi*sizeof *fds);
2654. > 	for(n=0 ; n < multi ; ++n)
2655.   		{
2656.   		if (pipe(fd) == -1)

apps/speed.c:2654:12: Loop condition is true. Entering loop body
2652.   
2653.   	fds=malloc(multi*sizeof *fds);
2654.   	for(n=0 ; n < multi ; ++n)
                   ^
2655.   		{
2656.   		if (pipe(fd) == -1)

apps/speed.c:2656:7: Taking false branch
2654.   	for(n=0 ; n < multi ; ++n)
2655.   		{
2656.   		if (pipe(fd) == -1)
              ^
2657.   			{
2658.   			fprintf(stderr, "pipe failure\n");

apps/speed.c:2661:3: 
2659.   			exit(1);
2660.   			}
2661. > 		fflush(stdout);
2662.   		fflush(stderr);
2663.   		if(fork())

apps/speed.c:2662:3: 
2660.   			}
2661.   		fflush(stdout);
2662. > 		fflush(stderr);
2663.   		if(fork())
2664.   			{

apps/speed.c:2663:6: Taking true branch
2661.   		fflush(stdout);
2662.   		fflush(stderr);
2663.   		if(fork())
             ^
2664.   			{
2665.   			close(fd[1]);

apps/speed.c:2665:4: 
2663.   		if(fork())
2664.   			{
2665. > 			close(fd[1]);
2666.   			fds[n]=fd[0];
2667.   			}

apps/speed.c:2666:4: 
2664.   			{
2665.   			close(fd[1]);
2666. > 			fds[n]=fd[0];
2667.   			}
2668.   		else

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

apps/speed.c:2654:24: 
2652.   
2653.   	fds=malloc(multi*sizeof *fds);
2654. > 	for(n=0 ; n < multi ; ++n)
2655.   		{
2656.   		if (pipe(fd) == -1)

apps/speed.c:2654:12: Loop condition is true. Entering loop body
2652.   
2653.   	fds=malloc(multi*sizeof *fds);
2654.   	for(n=0 ; n < multi ; ++n)
                   ^
2655.   		{
2656.   		if (pipe(fd) == -1)

apps/speed.c:2656:7: Taking false branch
2654.   	for(n=0 ; n < multi ; ++n)
2655.   		{
2656.   		if (pipe(fd) == -1)
              ^
2657.   			{
2658.   			fprintf(stderr, "pipe failure\n");

apps/speed.c:2661:3: 
2659.   			exit(1);
2660.   			}
2661. > 		fflush(stdout);
2662.   		fflush(stderr);
2663.   		if(fork())

apps/speed.c:2662:3: 
2660.   			}
2661.   		fflush(stdout);
2662. > 		fflush(stderr);
2663.   		if(fork())
2664.   			{

apps/speed.c:2663:6: Taking true branch
2661.   		fflush(stdout);
2662.   		fflush(stderr);
2663.   		if(fork())
             ^
2664.   			{
2665.   			close(fd[1]);

apps/speed.c:2665:4: 
2663.   		if(fork())
2664.   			{
2665. > 			close(fd[1]);
2666.   			fds[n]=fd[0];
2667.   			}

apps/speed.c:2666:4: 
2664.   			{
2665.   			close(fd[1]);
2666. > 			fds[n]=fd[0];
2667.   			}
2668.   		else

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

apps/speed.c:2654:24: 
2652.   
2653.   	fds=malloc(multi*sizeof *fds);
2654. > 	for(n=0 ; n < multi ; ++n)
2655.   		{
2656.   		if (pipe(fd) == -1)

apps/speed.c:2654:12: Loop condition is true. Entering loop body
2652.   
2653.   	fds=malloc(multi*sizeof *fds);
2654.   	for(n=0 ; n < multi ; ++n)
                   ^
2655.   		{
2656.   		if (pipe(fd) == -1)

apps/speed.c:2656:7: Taking false branch
2654.   	for(n=0 ; n < multi ; ++n)
2655.   		{
2656.   		if (pipe(fd) == -1)
              ^
2657.   			{
2658.   			fprintf(stderr, "pipe failure\n");

apps/speed.c:2661:3: 
2659.   			exit(1);
2660.   			}
2661. > 		fflush(stdout);
2662.   		fflush(stderr);
2663.   		if(fork())

apps/speed.c:2662:3: 
2660.   			}
2661.   		fflush(stdout);
2662. > 		fflush(stderr);
2663.   		if(fork())
2664.   			{

apps/speed.c:2663:6: Taking true branch
2661.   		fflush(stdout);
2662.   		fflush(stderr);
2663.   		if(fork())
             ^
2664.   			{
2665.   			close(fd[1]);

apps/speed.c:2665:4: 
2663.   		if(fork())
2664.   			{
2665. > 			close(fd[1]);
2666.   			fds[n]=fd[0];
2667.   			}

apps/speed.c:2666:4: 
2664.   			{
2665.   			close(fd[1]);
2666. > 			fds[n]=fd[0];
2667.   			}
2668.   		else

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

apps/speed.c:2654:24: 
2652.   
2653.   	fds=malloc(multi*sizeof *fds);
2654. > 	for(n=0 ; n < multi ; ++n)
2655.   		{
2656.   		if (pipe(fd) == -1)

apps/speed.c:2654:12: Loop condition is false. Leaving loop
2652.   
2653.   	fds=malloc(multi*sizeof *fds);
2654.   	for(n=0 ; n < multi ; ++n)
                   ^
2655.   		{
2656.   		if (pipe(fd) == -1)

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

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

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

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