mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-11 18:17:54 +00:00
Fix some coverity-found issues
This commit is contained in:
parent
28750a7d98
commit
17ef678ca5
@ -232,15 +232,14 @@ int git_attr_file__parse_buffer(
|
|||||||
|
|
||||||
while (!error && *scan) {
|
while (!error && *scan) {
|
||||||
/* allocate rule if needed */
|
/* allocate rule if needed */
|
||||||
if (!rule) {
|
if (!rule && !(rule = git__calloc(1, sizeof(*rule)))) {
|
||||||
if (!(rule = git__calloc(1, sizeof(*rule)))) {
|
error = -1;
|
||||||
error = -1;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
rule->match.flags = GIT_ATTR_FNMATCH_ALLOWNEG |
|
|
||||||
GIT_ATTR_FNMATCH_ALLOWMACRO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rule->match.flags =
|
||||||
|
GIT_ATTR_FNMATCH_ALLOWNEG | GIT_ATTR_FNMATCH_ALLOWMACRO;
|
||||||
|
|
||||||
/* parse the next "pattern attr attr attr" line */
|
/* parse the next "pattern attr attr attr" line */
|
||||||
if (!(error = git_attr_fnmatch__parse(
|
if (!(error = git_attr_fnmatch__parse(
|
||||||
&rule->match, &attrs->pool, context, &scan)) &&
|
&rule->match, &attrs->pool, context, &scan)) &&
|
||||||
|
@ -176,10 +176,9 @@ static int attr_cache_lookup(
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
entry = attr_cache_lookup_entry(cache, relfile);
|
entry = attr_cache_lookup_entry(cache, relfile);
|
||||||
if (!entry) {
|
if (!entry)
|
||||||
if ((error = attr_cache_make_entry(&entry, repo, relfile)) < 0)
|
error = attr_cache_make_entry(&entry, repo, relfile);
|
||||||
goto cleanup;
|
else if (entry->file[source] != NULL) {
|
||||||
} else if (entry->file[source] != NULL) {
|
|
||||||
file = entry->file[source];
|
file = entry->file[source];
|
||||||
GIT_REFCOUNT_INC(file);
|
GIT_REFCOUNT_INC(file);
|
||||||
}
|
}
|
||||||
@ -254,8 +253,7 @@ bool git_attr_cache__is_cached(
|
|||||||
khiter_t pos;
|
khiter_t pos;
|
||||||
git_attr_file_entry *entry;
|
git_attr_file_entry *entry;
|
||||||
|
|
||||||
if (!(cache = git_repository_attr_cache(repo)) ||
|
if (!cache || !(files = cache->files))
|
||||||
!(files = cache->files))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pos = git_strmap_lookup_index(files, filename);
|
pos = git_strmap_lookup_index(files, filename);
|
||||||
|
@ -32,9 +32,9 @@ static int parse_ignore_file(
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (!error && *scan) {
|
while (!error && *scan) {
|
||||||
if (!match) {
|
if (!match && !(match = git__calloc(1, sizeof(*match)))) {
|
||||||
match = git__calloc(1, sizeof(*match));
|
error = -1;
|
||||||
GITERR_CHECK_ALLOC(match);
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
match->flags = GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG;
|
match->flags = GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG;
|
||||||
|
@ -1880,8 +1880,9 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
|
|||||||
git_oid checksum_calculated, checksum_expected;
|
git_oid checksum_calculated, checksum_expected;
|
||||||
|
|
||||||
#define seek_forward(_increase) { \
|
#define seek_forward(_increase) { \
|
||||||
if (_increase >= buffer_size) \
|
if (_increase >= buffer_size) { \
|
||||||
return index_error_invalid("ran out of data while parsing"); \
|
error = index_error_invalid("ran out of data while parsing"); \
|
||||||
|
goto done; } \
|
||||||
buffer += _increase; \
|
buffer += _increase; \
|
||||||
buffer_size -= _increase;\
|
buffer_size -= _increase;\
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user