mirror of
				https://git.proxmox.com/git/libgit2
				synced 2025-11-04 14:08:17 +00:00 
			
		
		
		
	attr_cache_remove: don't remove given file
If `attr_cache_lookup_entry` fails to find the given file, make sure that we do not try to free the given file.
This commit is contained in:
		
							parent
							
								
									a0d3847983
								
							
						
					
					
						commit
						7f66a70eec
					
				@ -121,20 +121,22 @@ static int attr_cache_remove(git_attr_cache *cache, git_attr_file *file)
 | 
			
		||||
{
 | 
			
		||||
	int error = 0;
 | 
			
		||||
	git_attr_file_entry *entry;
 | 
			
		||||
	git_attr_file *old = NULL;
 | 
			
		||||
 | 
			
		||||
	if (!file)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	if ((error = attr_cache_lock(cache)) < 0)
 | 
			
		||||
		return error;
 | 
			
		||||
 | 
			
		||||
	if ((entry = attr_cache_lookup_entry(cache, file->entry->path)) != NULL)
 | 
			
		||||
		file = git__compare_and_swap(&entry->file[file->source], file, NULL);
 | 
			
		||||
		old = git__compare_and_swap(&entry->file[file->source], file, NULL);
 | 
			
		||||
 | 
			
		||||
	attr_cache_unlock(cache);
 | 
			
		||||
 | 
			
		||||
	if (file) {
 | 
			
		||||
		GIT_REFCOUNT_OWN(file, NULL);
 | 
			
		||||
		git_attr_file__free(file);
 | 
			
		||||
	if (old) {
 | 
			
		||||
		GIT_REFCOUNT_OWN(old, NULL);
 | 
			
		||||
		git_attr_file__free(old);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return error;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user