Fix infinite loop when checking timeouts
Move the iter pointer to the next item before doing any logic that might result in exiting from the current iteration of the loop since it would cause the same notification to be processed repeatedly resulting in an infinite loop. Fixes 362.
This commit is contained in:
		
							parent
							
								
									3c257eaeb7
								
							
						
					
					
						commit
						eb0a0f8602
					
				
							
								
								
									
										10
									
								
								src/dunst.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/dunst.c
									
									
									
									
									
								
							| @ -61,6 +61,13 @@ void check_timeouts(void) | ||||
|         while (iter) { | ||||
|                 notification *n = iter->data; | ||||
| 
 | ||||
|                 /*
 | ||||
|                  * Update iter to the next item before we either exit the | ||||
|                  * current iteration of the loop or potentially delete the | ||||
|                  * notification which would invalidate the pointer. | ||||
|                  */ | ||||
|                 iter = iter->next; | ||||
| 
 | ||||
|                 /* don't timeout when user is idle */ | ||||
|                 if (x_is_idle()) { | ||||
|                         n->start = time(NULL); | ||||
| @ -72,9 +79,6 @@ void check_timeouts(void) | ||||
|                         continue; | ||||
|                 } | ||||
| 
 | ||||
|                 /* shift iter before we possibly delete the current notification */ | ||||
|                 iter = iter->next; | ||||
| 
 | ||||
|                 /* remove old message */ | ||||
|                 if (difftime(time(NULL), n->start) > n->timeout) { | ||||
|                         notification_close(n, 1); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Nikos Tsipinakis
						Nikos Tsipinakis