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


apps/speed.c:2650:1: start of procedure do_multi()
2648.       }
2649.   
2650. > static int do_multi(int multi)
2651.   	{
2652.   	int n;

apps/speed.c:2655:2: 
2653.   	int fd[2];
2654.   	int *fds;
2655. > 	static char sep[]=":";
2656.   
2657.   	fds=malloc(multi*sizeof *fds);

apps/speed.c:2657:2: 
2655.   	static char sep[]=":";
2656.   
2657. > 	fds=malloc(multi*sizeof *fds);
2658.   	for(n=0 ; n < multi ; ++n)
2659.   		{

apps/speed.c:2658:6: 
2656.   
2657.   	fds=malloc(multi*sizeof *fds);
2658. > 	for(n=0 ; n < multi ; ++n)
2659.   		{
2660.   		if (pipe(fd) == -1)

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

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

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

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

apps/speed.c:2667:6: Taking true branch
2665.   		fflush(stdout);
2666.   		fflush(stderr);
2667.   		if(fork())
             ^
2668.   			{
2669.   			close(fd[1]);

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

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

apps/speed.c:2687:3: 
2685.   			return 0;
2686.   			}
2687. > 		printf("Forked child %d\n",n);
2688.   		}
2689.   

apps/speed.c:2658:24: 
2656.   
2657.   	fds=malloc(multi*sizeof *fds);
2658. > 	for(n=0 ; n < multi ; ++n)
2659.   		{
2660.   		if (pipe(fd) == -1)

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

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

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

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

apps/speed.c:2667:6: Taking true branch
2665.   		fflush(stdout);
2666.   		fflush(stderr);
2667.   		if(fork())
             ^
2668.   			{
2669.   			close(fd[1]);

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

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

apps/speed.c:2687:3: 
2685.   			return 0;
2686.   			}
2687. > 		printf("Forked child %d\n",n);
2688.   		}
2689.   

apps/speed.c:2658:24: 
2656.   
2657.   	fds=malloc(multi*sizeof *fds);
2658. > 	for(n=0 ; n < multi ; ++n)
2659.   		{
2660.   		if (pipe(fd) == -1)

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

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

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

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

apps/speed.c:2667:6: Taking true branch
2665.   		fflush(stdout);
2666.   		fflush(stderr);
2667.   		if(fork())
             ^
2668.   			{
2669.   			close(fd[1]);

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

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

apps/speed.c:2687:3: 
2685.   			return 0;
2686.   			}
2687. > 		printf("Forked child %d\n",n);
2688.   		}
2689.   

apps/speed.c:2658:24: 
2656.   
2657.   	fds=malloc(multi*sizeof *fds);
2658. > 	for(n=0 ; n < multi ; ++n)
2659.   		{
2660.   		if (pipe(fd) == -1)

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

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

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

apps/speed.c:2697:3: 
2695.   		char *p;
2696.   
2697. > 		f=fdopen(fds[n],"r");
2698.   		while(fgets(buf,sizeof buf,f))
2699.   			{

apps/speed.c:2698:9: 
2696.   
2697.   		f=fdopen(fds[n],"r");
2698. > 		while(fgets(buf,sizeof buf,f))
2699.   			{
2700.   			p=strchr(buf,'\n');
