summaryrefslogtreecommitdiff
path: root/src/refspec.c
diff options
context:
space:
mode:
authorEtienne Samson <samson.etienne@gmail.com>2018-04-18 21:41:44 +0200
committerEtienne Samson <samson.etienne@gmail.com>2018-04-20 19:37:24 +0200
commit592b200c60cae7ddba57d4d7787401c4f6d3ab47 (patch)
tree6ad7067cc2cd2870cfa31437029ad8faf5814799 /src/refspec.c
parentd906a8796cec1fc4d14144f53e505ab215bdab0c (diff)
downloadlibgit2-592b200c60cae7ddba57d4d7787401c4f6d3ab47.tar.gz
refspec: check for valid parameters in git_refspec__dwim_one
CID:1383993, "In git_refspec__dwim_one: All paths that lead to this null pointer comparison already dereference the pointer earlier (CWE-476)"
Diffstat (limited to 'src/refspec.c')
-rw-r--r--src/refspec.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/refspec.c b/src/refspec.c
index 01a77c97f..943a9c76a 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -304,6 +304,7 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
git_buf buf = GIT_BUF_INIT;
size_t j, pos;
git_remote_head key;
+ git_refspec *cur;
const char* formatters[] = {
GIT_REFS_DIR "%s",
@@ -312,7 +313,9 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
NULL
};
- git_refspec *cur = git__calloc(1, sizeof(git_refspec));
+ assert(out && spec && refs);
+
+ cur = git__calloc(1, sizeof(git_refspec));
GITERR_CHECK_ALLOC(cur);
cur->force = spec->force;