mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-10-29 05:40:27 -04:00 
			
		
		
		
	hook: don't remove from unitialized list
A lot of code calls spa_hook_remove() from error paths where the hook and therefore the list may not have been initialized. This leads to null-derefences.
This commit is contained in:
		
							parent
							
								
									b23b0e6125
								
							
						
					
					
						commit
						2394413ec3
					
				
					 2 changed files with 8 additions and 1 deletions
				
			
		|  | @ -382,6 +382,7 @@ static inline void spa_hook_list_prepend(struct spa_hook_list *list, | |||
| /** Remove a hook */ | ||||
| static inline void spa_hook_remove(struct spa_hook *hook) | ||||
| { | ||||
| 	if (spa_list_is_initialized(&hook->link)) | ||||
| 		spa_list_remove(&hook->link); | ||||
| 	if (hook->removed) | ||||
| 		hook->removed(hook); | ||||
|  |  | |||
|  | @ -419,6 +419,12 @@ PWTEST(utils_hook) | |||
| 	} | ||||
| 	pwtest_int_eq(count, 4); | ||||
| 	pwtest_int_eq(hook_free_count, 4); | ||||
| 
 | ||||
| 	/* remove a zeroed hook */ | ||||
| 	struct spa_hook hook; | ||||
| 	spa_zero(hook); | ||||
| 	spa_hook_remove(&hook); | ||||
| 
 | ||||
| 	return PWTEST_PASS; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Thomas Weißschuh
						Thomas Weißschuh