What is a Conditionally Uninitialized Variable? The return value of a function that is potentially used to initialize a local variable is not checked. Therefore, reading the local variable may result in undefined behavior.
3 instances of this defect were found in the following locations:
/* skip ignored items that are not already in the index */
if ((flags & GIT_INDEX_ADD_FORCE) == 0 &&
git_iterator_current_is_ignored(wditer) &&
index_find(&existing, index, wd->path, 0, 0, true) < 0) <------ HERE
continue;
/* If index->entries is sorted case-insensitively, then we need
* to re-sort it case-sensitively before writing */
if (index->ignore_case) {
git_vector_dup(&case_sorted, &index->entries, git_index_entry_cmp); <------ HERE
git_vector_sort(&case_sorted);
entries = &case_sorted;
return -1;
/* get out the hash for all the contents we've appended to the file */
git_filebuf_hash(&hash_final, file); <------ HERE
/* write it at the end of the file */
What is a Conditionally Uninitialized Variable? The return value of a function that is potentially used to initialize a local variable is not checked. Therefore, reading the local variable may result in undefined behavior.
3 instances of this defect were found in the following locations:
Instance 1 File :
src/index.c
Enclosing Function :git_index_remove_directory
Function :index_find
https://github.com/siva-msft/libgit2/blob/53d0ba4625cc355f03d925ec26fc92310dd89fee/src/index.c#L1196 Issue in: posCode extract:
How can I fix it? Correct reference usage found in
src/index.c
at line2480
. https://github.com/siva-msft/libgit2/blob/53d0ba4625cc355f03d925ec26fc92310dd89fee/src/index.c#L2480 Code extract:Instance 2 File :
src/index.c
Enclosing Function :write_entries
Function :git_vector_dup
https://github.com/siva-msft/libgit2/blob/53d0ba4625cc355f03d925ec26fc92310dd89fee/src/index.c#L2116 Issue in: _casesortedCode extract:
How can I fix it? Correct reference usage found in
src/index.c
at line2656
. https://github.com/siva-msft/libgit2/blob/53d0ba4625cc355f03d925ec26fc92310dd89fee/src/index.c#L2656 Code extract:Instance 3 File :
src/index.c
Enclosing Function :write_index
Function :git_filebuf_hash
https://github.com/siva-msft/libgit2/blob/53d0ba4625cc355f03d925ec26fc92310dd89fee/src/index.c#L2308 Issue in: _hashfinalCode extract:
How can I fix it? Correct reference usage found in
src/indexer.c
at line1003
. https://github.com/siva-msft/libgit2/blob/53d0ba4625cc355f03d925ec26fc92310dd89fee/src/indexer.c#L1003 Code extract: