mirror of
				https://git.proxmox.com/git/libgit2
				synced 2025-10-31 10:53:57 +00:00 
			
		
		
		
	submodule: plug a few leaks
This commit is contained in:
		
							parent
							
								
									aebddbe736
								
							
						
					
					
						commit
						ab8f2c669a
					
				| @ -170,7 +170,7 @@ static int name_from_path(git_buf *out, git_config *cfg, const char *path) | ||||
| 
 | ||||
| 		git_buf_clear(out); | ||||
| 		git_buf_put(out, fdot + 1, ldot - fdot - 1); | ||||
| 		return 0; | ||||
| 		goto cleanup; | ||||
| 	} | ||||
| 
 | ||||
| 	if (error == GIT_ITEROVER) { | ||||
| @ -178,6 +178,8 @@ static int name_from_path(git_buf *out, git_config *cfg, const char *path) | ||||
| 		error = GIT_ENOTFOUND; | ||||
| 	} | ||||
| 
 | ||||
| cleanup: | ||||
| 	git_config_iterator_free(iter); | ||||
| 	return error; | ||||
| } | ||||
| 
 | ||||
| @ -1701,7 +1703,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg) | ||||
| 			GITERR_CHECK_ALLOC(sm->path); | ||||
| 		} | ||||
| 	} else if (error != GIT_ENOTFOUND) { | ||||
| 		return error; | ||||
| 		goto cleanup; | ||||
| 	} | ||||
| 
 | ||||
| 	if ((error = get_value(&value, cfg, &key, sm->name, "url")) == 0) { | ||||
| @ -1709,7 +1711,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg) | ||||
| 		sm->url = git__strdup(value); | ||||
| 		GITERR_CHECK_ALLOC(sm->url); | ||||
| 	} else if (error != GIT_ENOTFOUND) { | ||||
| 		return error; | ||||
| 		goto cleanup; | ||||
| 	} | ||||
| 
 | ||||
| 	if ((error = get_value(&value, cfg, &key, sm->name, "branch")) == 0) { | ||||
| @ -1717,40 +1719,44 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg) | ||||
| 		sm->branch = git__strdup(value); | ||||
| 		GITERR_CHECK_ALLOC(sm->branch); | ||||
| 	} else if (error != GIT_ENOTFOUND) { | ||||
| 		return error; | ||||
| 		goto cleanup; | ||||
| 	} | ||||
| 
 | ||||
| 	if ((error = get_value(&value, cfg, &key, sm->name, "update")) == 0) { | ||||
| 		in_config = 1; | ||||
| 		if ((error = git_submodule_parse_update(&sm->update, value)) < 0) | ||||
| 			return error; | ||||
| 			goto cleanup; | ||||
| 		sm->update_default = sm->update; | ||||
| 	} else if (error != GIT_ENOTFOUND) { | ||||
| 		return error; | ||||
| 		goto cleanup; | ||||
| 	} | ||||
| 
 | ||||
| 	if ((error = get_value(&value, cfg, &key, sm->name, "fetchRecurseSubmodules")) == 0) { | ||||
| 		in_config = 1; | ||||
| 		if ((error = git_submodule_parse_recurse(&sm->fetch_recurse, value)) < 0) | ||||
| 			return error; | ||||
| 			goto cleanup; | ||||
| 		sm->fetch_recurse_default = sm->fetch_recurse; | ||||
| 	} else if (error != GIT_ENOTFOUND) { | ||||
| 		return error; | ||||
| 		goto cleanup; | ||||
| 	} | ||||
| 
 | ||||
| 	if ((error = get_value(&value, cfg, &key, sm->name, "ignore")) == 0) { | ||||
| 		in_config = 1; | ||||
| 		if ((error = git_submodule_parse_ignore(&sm->ignore, value)) < 0) | ||||
| 			return error; | ||||
| 			goto cleanup; | ||||
| 		sm->ignore_default = sm->ignore; | ||||
| 	} else if (error != GIT_ENOTFOUND) { | ||||
| 		return error; | ||||
| 		goto cleanup; | ||||
| 	} | ||||
| 
 | ||||
| 	if (in_config) | ||||
| 		sm->flags |= GIT_SUBMODULE_STATUS_IN_CONFIG; | ||||
| 
 | ||||
| 	return 0; | ||||
| 	error = 0; | ||||
| 
 | ||||
| cleanup: | ||||
| 	git_buf_free(&key); | ||||
| 	return error; | ||||
| } | ||||
| 
 | ||||
| static int submodule_load_each(const git_config_entry *entry, void *payload) | ||||
| @ -1784,8 +1790,10 @@ static int submodule_load_each(const git_config_entry *entry, void *payload) | ||||
| 	 * already inserted, we've already loaded it, so we skip. | ||||
| 	 */ | ||||
| 	pos = git_strmap_lookup_index(map, name.ptr); | ||||
| 	if (git_strmap_valid_index(map, pos)) | ||||
| 		return 0; | ||||
| 	if (git_strmap_valid_index(map, pos)) { | ||||
| 		error = 0; | ||||
| 		goto done; | ||||
| 	} | ||||
| 
 | ||||
| 	if ((error = submodule_alloc(&sm, data->repo, name.ptr)) < 0) | ||||
| 		goto done; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Carlos Martín Nieto
						Carlos Martín Nieto