Fix potential segfault in waitForInput()
Since the addition of build-max-log-size, a call to handleChildOutput() can result in cancellation of a goal. This invalidated the "j" iterator in the waitForInput() loop, even though it was still used afterwards. Likewise for the maxSilentTime handling. Probably fixes #231. At least it gets rid of the valgrind warnings.
This commit is contained in:
		
							parent
							
								
									90dc50b07c
								
							
						
					
					
						commit
						acb8facbbc
					
				
					 1 changed files with 5 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -3229,13 +3229,14 @@ void Worker::waitForInput()
 | 
			
		|||
                    printMsg(lvlVomit, format("%1%: read %2% bytes")
 | 
			
		||||
                        % goal->getName() % rd);
 | 
			
		||||
                    string data((char *) buffer, rd);
 | 
			
		||||
                    goal->handleChildOutput(*k, data);
 | 
			
		||||
                    j->second.lastOutput = after;
 | 
			
		||||
                    goal->handleChildOutput(*k, data);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (settings.maxSilentTime != 0 &&
 | 
			
		||||
        if (goal->getExitCode() == Goal::ecBusy &&
 | 
			
		||||
            settings.maxSilentTime != 0 &&
 | 
			
		||||
            j->second.respectTimeouts &&
 | 
			
		||||
            after - j->second.lastOutput >= (time_t) settings.maxSilentTime)
 | 
			
		||||
        {
 | 
			
		||||
| 
						 | 
				
			
			@ -3245,7 +3246,8 @@ void Worker::waitForInput()
 | 
			
		|||
            goal->cancel(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (settings.buildTimeout != 0 &&
 | 
			
		||||
        else if (goal->getExitCode() == Goal::ecBusy &&
 | 
			
		||||
            settings.buildTimeout != 0 &&
 | 
			
		||||
            j->second.respectTimeouts &&
 | 
			
		||||
            after - j->second.timeStarted >= (time_t) settings.buildTimeout)
 | 
			
		||||
        {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue