Skip to content

Commit 592b200

Browse files
committed
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)"
1 parent d906a87 commit 592b200

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/refspec.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
304304
git_buf buf = GIT_BUF_INIT;
305305
size_t j, pos;
306306
git_remote_head key;
307+
git_refspec *cur;
307308

308309
const char* formatters[] = {
309310
GIT_REFS_DIR "%s",
@@ -312,7 +313,9 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
312313
NULL
313314
};
314315

315-
git_refspec *cur = git__calloc(1, sizeof(git_refspec));
316+
assert(out && spec && refs);
317+
318+
cur = git__calloc(1, sizeof(git_refspec));
316319
GITERR_CHECK_ALLOC(cur);
317320

318321
cur->force = spec->force;

0 commit comments

Comments
 (0)