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


apps/speed.c:2825:1: start of procedure do_multi()
2823.       }
2824.   
2825. > static int do_multi(int multi)
2826.   	{
2827.   	int n;

apps/speed.c:2830:2: 
2828.   	int fd[2];
2829.   	int *fds;
2830. > 	static char sep[]=":";
2831.   
2832.   	fds=malloc(multi*sizeof *fds);

apps/speed.c:2832:2: 
2830.   	static char sep[]=":";
2831.   
2832. > 	fds=malloc(multi*sizeof *fds);
2833.   	for(n=0 ; n < multi ; ++n)
2834.   		{

apps/speed.c:2833:6: 
2831.   
2832.   	fds=malloc(multi*sizeof *fds);
2833. > 	for(n=0 ; n < multi ; ++n)
2834.   		{
2835.   		if (pipe(fd) == -1)

apps/speed.c:2833:12: Loop condition is true. Entering loop body
2831.   
2832.   	fds=malloc(multi*sizeof *fds);
2833.   	for(n=0 ; n < multi ; ++n)
                   ^
2834.   		{
2835.   		if (pipe(fd) == -1)

apps/speed.c:2835:7: Taking false branch
2833.   	for(n=0 ; n < multi ; ++n)
2834.   		{
2835.   		if (pipe(fd) == -1)
              ^
2836.   			{
2837.   			fprintf(stderr, "pipe failure\n");

apps/speed.c:2840:3: 
2838.   			exit(1);
2839.   			}
2840. > 		fflush(stdout);
2841.   		fflush(stderr);
2842.   		if(fork())

apps/speed.c:2841:3: 
2839.   			}
2840.   		fflush(stdout);
2841. > 		fflush(stderr);
2842.   		if(fork())
2843.   			{

apps/speed.c:2842:6: Taking true branch
2840.   		fflush(stdout);
2841.   		fflush(stderr);
2842.   		if(fork())
             ^
2843.   			{
2844.   			close(fd[1]);

apps/speed.c:2844:4: 
2842.   		if(fork())
2843.   			{
2844. > 			close(fd[1]);
2845.   			fds[n]=fd[0];
2846.   			}

apps/speed.c:2845:4: 
2843.   			{
2844.   			close(fd[1]);
2845. > 			fds[n]=fd[0];
2846.   			}
2847.   		else

apps/speed.c:2862:3: 
2860.   			return 0;
2861.   			}
2862. > 		printf("Forked child %d\n",n);
2863.   		}
2864.   

apps/speed.c:2833:24: 
2831.   
2832.   	fds=malloc(multi*sizeof *fds);
2833. > 	for(n=0 ; n < multi ; ++n)
2834.   		{
2835.   		if (pipe(fd) == -1)

apps/speed.c:2833:12: Loop condition is true. Entering loop body
2831.   
2832.   	fds=malloc(multi*sizeof *fds);
2833.   	for(n=0 ; n < multi ; ++n)
                   ^
2834.   		{
2835.   		if (pipe(fd) == -1)

apps/speed.c:2835:7: Taking false branch
2833.   	for(n=0 ; n < multi ; ++n)
2834.   		{
2835.   		if (pipe(fd) == -1)
              ^
2836.   			{
2837.   			fprintf(stderr, "pipe failure\n");

apps/speed.c:2840:3: 
2838.   			exit(1);
2839.   			}
2840. > 		fflush(stdout);
2841.   		fflush(stderr);
2842.   		if(fork())

apps/speed.c:2841:3: 
2839.   			}
2840.   		fflush(stdout);
2841. > 		fflush(stderr);
2842.   		if(fork())
2843.   			{

apps/speed.c:2842:6: Taking true branch
2840.   		fflush(stdout);
2841.   		fflush(stderr);
2842.   		if(fork())
             ^
2843.   			{
2844.   			close(fd[1]);

apps/speed.c:2844:4: 
2842.   		if(fork())
2843.   			{
2844. > 			close(fd[1]);
2845.   			fds[n]=fd[0];
2846.   			}

apps/speed.c:2845:4: 
2843.   			{
2844.   			close(fd[1]);
2845. > 			fds[n]=fd[0];
2846.   			}
2847.   		else

apps/speed.c:2862:3: 
2860.   			return 0;
2861.   			}
2862. > 		printf("Forked child %d\n",n);
2863.   		}
2864.   

apps/speed.c:2833:24: 
2831.   
2832.   	fds=malloc(multi*sizeof *fds);
2833. > 	for(n=0 ; n < multi ; ++n)
2834.   		{
2835.   		if (pipe(fd) == -1)

apps/speed.c:2833:12: Loop condition is true. Entering loop body
2831.   
2832.   	fds=malloc(multi*sizeof *fds);
2833.   	for(n=0 ; n < multi ; ++n)
                   ^
2834.   		{
2835.   		if (pipe(fd) == -1)

apps/speed.c:2835:7: Taking false branch
2833.   	for(n=0 ; n < multi ; ++n)
2834.   		{
2835.   		if (pipe(fd) == -1)
              ^
2836.   			{
2837.   			fprintf(stderr, "pipe failure\n");

apps/speed.c:2840:3: 
2838.   			exit(1);
2839.   			}
2840. > 		fflush(stdout);
2841.   		fflush(stderr);
2842.   		if(fork())

apps/speed.c:2841:3: 
2839.   			}
2840.   		fflush(stdout);
2841. > 		fflush(stderr);
2842.   		if(fork())
2843.   			{

apps/speed.c:2842:6: Taking true branch
2840.   		fflush(stdout);
2841.   		fflush(stderr);
2842.   		if(fork())
             ^
2843.   			{
2844.   			close(fd[1]);

apps/speed.c:2844:4: 
2842.   		if(fork())
2843.   			{
2844. > 			close(fd[1]);
2845.   			fds[n]=fd[0];
2846.   			}

apps/speed.c:2845:4: 
2843.   			{
2844.   			close(fd[1]);
2845. > 			fds[n]=fd[0];
2846.   			}
2847.   		else

apps/speed.c:2862:3: 
2860.   			return 0;
2861.   			}
2862. > 		printf("Forked child %d\n",n);
2863.   		}
2864.   

apps/speed.c:2833:24: 
2831.   
2832.   	fds=malloc(multi*sizeof *fds);
2833. > 	for(n=0 ; n < multi ; ++n)
2834.   		{
2835.   		if (pipe(fd) == -1)

apps/speed.c:2833:12: Loop condition is false. Leaving loop
2831.   
2832.   	fds=malloc(multi*sizeof *fds);
2833.   	for(n=0 ; n < multi ; ++n)
                   ^
2834.   		{
2835.   		if (pipe(fd) == -1)

apps/speed.c:2866:6: 
2864.   
2865.   	/* for now, assume the pipe is long enough to take all the output */
2866. > 	for(n=0 ; n < multi ; ++n)
2867.   		{
2868.   		FILE *f;

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

apps/speed.c:2872:3: 
2870.   		char *p;
2871.   
2872. > 		f=fdopen(fds[n],"r");
2873.   		while(fgets(buf,sizeof buf,f))
2874.   			{

apps/speed.c:2873:9: 
2871.   
2872.   		f=fdopen(fds[n],"r");
2873. > 		while(fgets(buf,sizeof buf,f))
2874.   			{
2875.   			p=strchr(buf,'\n');
