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


apps/speed.c:2779:1: start of procedure do_multi()
2777.       }
2778.   
2779. > static int do_multi(int multi)
2780.   	{
2781.   	int n;

apps/speed.c:2784:2: 
2782.   	int fd[2];
2783.   	int *fds;
2784. > 	static char sep[]=":";
2785.   
2786.   	fds=malloc(multi*sizeof *fds);

apps/speed.c:2786:2: 
2784.   	static char sep[]=":";
2785.   
2786. > 	fds=malloc(multi*sizeof *fds);
2787.   	for(n=0 ; n < multi ; ++n)
2788.   		{

apps/speed.c:2787:6: 
2785.   
2786.   	fds=malloc(multi*sizeof *fds);
2787. > 	for(n=0 ; n < multi ; ++n)
2788.   		{
2789.   		if (pipe(fd) == -1)

apps/speed.c:2787:12: Loop condition is true. Entering loop body
2785.   
2786.   	fds=malloc(multi*sizeof *fds);
2787.   	for(n=0 ; n < multi ; ++n)
                   ^
2788.   		{
2789.   		if (pipe(fd) == -1)

apps/speed.c:2789:7: Taking false branch
2787.   	for(n=0 ; n < multi ; ++n)
2788.   		{
2789.   		if (pipe(fd) == -1)
              ^
2790.   			{
2791.   			fprintf(stderr, "pipe failure\n");

apps/speed.c:2794:3: 
2792.   			exit(1);
2793.   			}
2794. > 		fflush(stdout);
2795.   		fflush(stderr);
2796.   		if(fork())

apps/speed.c:2795:3: 
2793.   			}
2794.   		fflush(stdout);
2795. > 		fflush(stderr);
2796.   		if(fork())
2797.   			{

apps/speed.c:2796:6: Taking true branch
2794.   		fflush(stdout);
2795.   		fflush(stderr);
2796.   		if(fork())
             ^
2797.   			{
2798.   			close(fd[1]);

apps/speed.c:2798:4: 
2796.   		if(fork())
2797.   			{
2798. > 			close(fd[1]);
2799.   			fds[n]=fd[0];
2800.   			}

apps/speed.c:2799:4: 
2797.   			{
2798.   			close(fd[1]);
2799. > 			fds[n]=fd[0];
2800.   			}
2801.   		else

apps/speed.c:2816:3: 
2814.   			return 0;
2815.   			}
2816. > 		printf("Forked child %d\n",n);
2817.   		}
2818.   

apps/speed.c:2787:24: 
2785.   
2786.   	fds=malloc(multi*sizeof *fds);
2787. > 	for(n=0 ; n < multi ; ++n)
2788.   		{
2789.   		if (pipe(fd) == -1)

apps/speed.c:2787:12: Loop condition is true. Entering loop body
2785.   
2786.   	fds=malloc(multi*sizeof *fds);
2787.   	for(n=0 ; n < multi ; ++n)
                   ^
2788.   		{
2789.   		if (pipe(fd) == -1)

apps/speed.c:2789:7: Taking false branch
2787.   	for(n=0 ; n < multi ; ++n)
2788.   		{
2789.   		if (pipe(fd) == -1)
              ^
2790.   			{
2791.   			fprintf(stderr, "pipe failure\n");

apps/speed.c:2794:3: 
2792.   			exit(1);
2793.   			}
2794. > 		fflush(stdout);
2795.   		fflush(stderr);
2796.   		if(fork())

apps/speed.c:2795:3: 
2793.   			}
2794.   		fflush(stdout);
2795. > 		fflush(stderr);
2796.   		if(fork())
2797.   			{

apps/speed.c:2796:6: Taking true branch
2794.   		fflush(stdout);
2795.   		fflush(stderr);
2796.   		if(fork())
             ^
2797.   			{
2798.   			close(fd[1]);

apps/speed.c:2798:4: 
2796.   		if(fork())
2797.   			{
2798. > 			close(fd[1]);
2799.   			fds[n]=fd[0];
2800.   			}

apps/speed.c:2799:4: 
2797.   			{
2798.   			close(fd[1]);
2799. > 			fds[n]=fd[0];
2800.   			}
2801.   		else

apps/speed.c:2816:3: 
2814.   			return 0;
2815.   			}
2816. > 		printf("Forked child %d\n",n);
2817.   		}
2818.   

apps/speed.c:2787:24: 
2785.   
2786.   	fds=malloc(multi*sizeof *fds);
2787. > 	for(n=0 ; n < multi ; ++n)
2788.   		{
2789.   		if (pipe(fd) == -1)

apps/speed.c:2787:12: Loop condition is true. Entering loop body
2785.   
2786.   	fds=malloc(multi*sizeof *fds);
2787.   	for(n=0 ; n < multi ; ++n)
                   ^
2788.   		{
2789.   		if (pipe(fd) == -1)

apps/speed.c:2789:7: Taking false branch
2787.   	for(n=0 ; n < multi ; ++n)
2788.   		{
2789.   		if (pipe(fd) == -1)
              ^
2790.   			{
2791.   			fprintf(stderr, "pipe failure\n");

apps/speed.c:2794:3: 
2792.   			exit(1);
2793.   			}
2794. > 		fflush(stdout);
2795.   		fflush(stderr);
2796.   		if(fork())

apps/speed.c:2795:3: 
2793.   			}
2794.   		fflush(stdout);
2795. > 		fflush(stderr);
2796.   		if(fork())
2797.   			{

apps/speed.c:2796:6: Taking true branch
2794.   		fflush(stdout);
2795.   		fflush(stderr);
2796.   		if(fork())
             ^
2797.   			{
2798.   			close(fd[1]);

apps/speed.c:2798:4: 
2796.   		if(fork())
2797.   			{
2798. > 			close(fd[1]);
2799.   			fds[n]=fd[0];
2800.   			}

apps/speed.c:2799:4: 
2797.   			{
2798.   			close(fd[1]);
2799. > 			fds[n]=fd[0];
2800.   			}
2801.   		else

apps/speed.c:2816:3: 
2814.   			return 0;
2815.   			}
2816. > 		printf("Forked child %d\n",n);
2817.   		}
2818.   

apps/speed.c:2787:24: 
2785.   
2786.   	fds=malloc(multi*sizeof *fds);
2787. > 	for(n=0 ; n < multi ; ++n)
2788.   		{
2789.   		if (pipe(fd) == -1)

apps/speed.c:2787:12: Loop condition is false. Leaving loop
2785.   
2786.   	fds=malloc(multi*sizeof *fds);
2787.   	for(n=0 ; n < multi ; ++n)
                   ^
2788.   		{
2789.   		if (pipe(fd) == -1)

apps/speed.c:2820:6: 
2818.   
2819.   	/* for now, assume the pipe is long enough to take all the output */
2820. > 	for(n=0 ; n < multi ; ++n)
2821.   		{
2822.   		FILE *f;

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

apps/speed.c:2826:3: 
2824.   		char *p;
2825.   
2826. > 		f=fdopen(fds[n],"r");
2827.   		while(fgets(buf,sizeof buf,f))
2828.   			{

apps/speed.c:2827:9: 
2825.   
2826.   		f=fdopen(fds[n],"r");
2827. > 		while(fgets(buf,sizeof buf,f))
2828.   			{
2829.   			p=strchr(buf,'\n');
