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


apps/speed.c:2740:1: start of procedure do_multi()
2738.       }
2739.   
2740. > static int do_multi(int multi)
2741.   	{
2742.   	int n;

apps/speed.c:2745:2: 
2743.   	int fd[2];
2744.   	int *fds;
2745. > 	static char sep[]=":";
2746.   
2747.   	fds=malloc(multi*sizeof *fds);

apps/speed.c:2747:2: 
2745.   	static char sep[]=":";
2746.   
2747. > 	fds=malloc(multi*sizeof *fds);
2748.   	for(n=0 ; n < multi ; ++n)
2749.   		{

apps/speed.c:2748:6: 
2746.   
2747.   	fds=malloc(multi*sizeof *fds);
2748. > 	for(n=0 ; n < multi ; ++n)
2749.   		{
2750.   		if (pipe(fd) == -1)

apps/speed.c:2748:12: Loop condition is true. Entering loop body
2746.   
2747.   	fds=malloc(multi*sizeof *fds);
2748.   	for(n=0 ; n < multi ; ++n)
                   ^
2749.   		{
2750.   		if (pipe(fd) == -1)

apps/speed.c:2750:7: Taking false branch
2748.   	for(n=0 ; n < multi ; ++n)
2749.   		{
2750.   		if (pipe(fd) == -1)
              ^
2751.   			{
2752.   			fprintf(stderr, "pipe failure\n");

apps/speed.c:2755:3: 
2753.   			exit(1);
2754.   			}
2755. > 		fflush(stdout);
2756.   		fflush(stderr);
2757.   		if(fork())

apps/speed.c:2756:3: 
2754.   			}
2755.   		fflush(stdout);
2756. > 		fflush(stderr);
2757.   		if(fork())
2758.   			{

apps/speed.c:2757:6: Taking true branch
2755.   		fflush(stdout);
2756.   		fflush(stderr);
2757.   		if(fork())
             ^
2758.   			{
2759.   			close(fd[1]);

apps/speed.c:2759:4: 
2757.   		if(fork())
2758.   			{
2759. > 			close(fd[1]);
2760.   			fds[n]=fd[0];
2761.   			}

apps/speed.c:2760:4: 
2758.   			{
2759.   			close(fd[1]);
2760. > 			fds[n]=fd[0];
2761.   			}
2762.   		else

apps/speed.c:2777:3: 
2775.   			return 0;
2776.   			}
2777. > 		printf("Forked child %d\n",n);
2778.   		}
2779.   

apps/speed.c:2748:24: 
2746.   
2747.   	fds=malloc(multi*sizeof *fds);
2748. > 	for(n=0 ; n < multi ; ++n)
2749.   		{
2750.   		if (pipe(fd) == -1)

apps/speed.c:2748:12: Loop condition is true. Entering loop body
2746.   
2747.   	fds=malloc(multi*sizeof *fds);
2748.   	for(n=0 ; n < multi ; ++n)
                   ^
2749.   		{
2750.   		if (pipe(fd) == -1)

apps/speed.c:2750:7: Taking false branch
2748.   	for(n=0 ; n < multi ; ++n)
2749.   		{
2750.   		if (pipe(fd) == -1)
              ^
2751.   			{
2752.   			fprintf(stderr, "pipe failure\n");

apps/speed.c:2755:3: 
2753.   			exit(1);
2754.   			}
2755. > 		fflush(stdout);
2756.   		fflush(stderr);
2757.   		if(fork())

apps/speed.c:2756:3: 
2754.   			}
2755.   		fflush(stdout);
2756. > 		fflush(stderr);
2757.   		if(fork())
2758.   			{

apps/speed.c:2757:6: Taking true branch
2755.   		fflush(stdout);
2756.   		fflush(stderr);
2757.   		if(fork())
             ^
2758.   			{
2759.   			close(fd[1]);

apps/speed.c:2759:4: 
2757.   		if(fork())
2758.   			{
2759. > 			close(fd[1]);
2760.   			fds[n]=fd[0];
2761.   			}

apps/speed.c:2760:4: 
2758.   			{
2759.   			close(fd[1]);
2760. > 			fds[n]=fd[0];
2761.   			}
2762.   		else

apps/speed.c:2777:3: 
2775.   			return 0;
2776.   			}
2777. > 		printf("Forked child %d\n",n);
2778.   		}
2779.   

apps/speed.c:2748:24: 
2746.   
2747.   	fds=malloc(multi*sizeof *fds);
2748. > 	for(n=0 ; n < multi ; ++n)
2749.   		{
2750.   		if (pipe(fd) == -1)

apps/speed.c:2748:12: Loop condition is true. Entering loop body
2746.   
2747.   	fds=malloc(multi*sizeof *fds);
2748.   	for(n=0 ; n < multi ; ++n)
                   ^
2749.   		{
2750.   		if (pipe(fd) == -1)

apps/speed.c:2750:7: Taking false branch
2748.   	for(n=0 ; n < multi ; ++n)
2749.   		{
2750.   		if (pipe(fd) == -1)
              ^
2751.   			{
2752.   			fprintf(stderr, "pipe failure\n");

apps/speed.c:2755:3: 
2753.   			exit(1);
2754.   			}
2755. > 		fflush(stdout);
2756.   		fflush(stderr);
2757.   		if(fork())

apps/speed.c:2756:3: 
2754.   			}
2755.   		fflush(stdout);
2756. > 		fflush(stderr);
2757.   		if(fork())
2758.   			{

apps/speed.c:2757:6: Taking true branch
2755.   		fflush(stdout);
2756.   		fflush(stderr);
2757.   		if(fork())
             ^
2758.   			{
2759.   			close(fd[1]);

apps/speed.c:2759:4: 
2757.   		if(fork())
2758.   			{
2759. > 			close(fd[1]);
2760.   			fds[n]=fd[0];
2761.   			}

apps/speed.c:2760:4: 
2758.   			{
2759.   			close(fd[1]);
2760. > 			fds[n]=fd[0];
2761.   			}
2762.   		else

apps/speed.c:2777:3: 
2775.   			return 0;
2776.   			}
2777. > 		printf("Forked child %d\n",n);
2778.   		}
2779.   

apps/speed.c:2748:24: 
2746.   
2747.   	fds=malloc(multi*sizeof *fds);
2748. > 	for(n=0 ; n < multi ; ++n)
2749.   		{
2750.   		if (pipe(fd) == -1)

apps/speed.c:2748:12: Loop condition is false. Leaving loop
2746.   
2747.   	fds=malloc(multi*sizeof *fds);
2748.   	for(n=0 ; n < multi ; ++n)
                   ^
2749.   		{
2750.   		if (pipe(fd) == -1)

apps/speed.c:2781:6: 
2779.   
2780.   	/* for now, assume the pipe is long enough to take all the output */
2781. > 	for(n=0 ; n < multi ; ++n)
2782.   		{
2783.   		FILE *f;

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

apps/speed.c:2787:3: 
2785.   		char *p;
2786.   
2787. > 		f=fdopen(fds[n],"r");
2788.   		while(fgets(buf,sizeof buf,f))
2789.   			{

apps/speed.c:2788:9: 
2786.   
2787.   		f=fdopen(fds[n],"r");
2788. > 		while(fgets(buf,sizeof buf,f))
2789.   			{
2790.   			p=strchr(buf,'\n');
