Commit b3c524d1048af85158296bc6aee4fbf57241a208

Vicent Martí 2011-09-18T19:46:12

Merge pull request #399 from carlosmn/free-null Add checks for NULL to the config and remote free functions

diff --git a/src/config.c b/src/config.c
index 975e353..f233e76 100644
--- a/src/config.c
+++ b/src/config.c
@@ -25,6 +25,9 @@ void git_config_free(git_config *cfg)
 	git_config_file *file;
 	file_internal *internal;
 
+	if (cfg == NULL)
+		return;
+
 	for(i = 0; i < cfg->files.length; ++i){
 		internal = git_vector_get(&cfg->files, i);
 		file = internal->file;
diff --git a/src/remote.c b/src/remote.c
index 74a238d..ad9dedc 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -249,6 +249,9 @@ int git_remote_update_tips(struct git_remote *remote)
 
 void git_remote_free(git_remote *remote)
 {
+	if (remote == NULL)
+		return;
+
 	free(remote->fetch.src);
 	free(remote->fetch.dst);
 	free(remote->push.src);