mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Merge pull request #2370 from RyanDwyer/transactions-use-after-free
Fix use after free in transactions
This commit is contained in:
		
						commit
						92a4bc646a
					
				
					 1 changed files with 6 additions and 0 deletions
				
			
		| 
						 | 
					@ -364,7 +364,13 @@ static void set_instructions_ready(struct sway_view *view, int index) {
 | 
				
			||||||
		struct sway_transaction_instruction *instruction =
 | 
							struct sway_transaction_instruction *instruction =
 | 
				
			||||||
			view->swayc->instructions->items[i];
 | 
								view->swayc->instructions->items[i];
 | 
				
			||||||
		if (!instruction->ready) {
 | 
							if (!instruction->ready) {
 | 
				
			||||||
 | 
								// set_instruction_ready can remove instructions from the list we're
 | 
				
			||||||
 | 
								// iterating
 | 
				
			||||||
 | 
								size_t length = view->swayc->instructions->length;
 | 
				
			||||||
			set_instruction_ready(instruction);
 | 
								set_instruction_ready(instruction);
 | 
				
			||||||
 | 
								size_t num_removed = length - view->swayc->instructions->length;
 | 
				
			||||||
 | 
								i -= num_removed;
 | 
				
			||||||
 | 
								index -= num_removed;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue