summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/attr_file.c3
-rw-r--r--src/pool.c5
2 files changed, 7 insertions, 1 deletions
diff --git a/src/attr_file.c b/src/attr_file.c
index 85cd87624..d059cfec7 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -397,7 +397,8 @@ int git_attr_fnmatch__parse(
*base = scan;
- spec->length = scan - pattern;
+ if ((spec->length = scan - pattern) == 0)
+ return GIT_ENOTFOUND;
if (pattern[spec->length - 1] == '/') {
spec->length--;
diff --git a/src/pool.c b/src/pool.c
index b3cd49665..d484769e9 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -194,6 +194,11 @@ char *git_pool_strndup(git_pool *pool, const char *str, size_t n)
assert(pool && str && pool->item_size == sizeof(char));
+ if (n + 1 == 0) {
+ giterr_set_oom();
+ return NULL;
+ }
+
if ((ptr = git_pool_malloc(pool, (uint32_t)(n + 1))) != NULL) {
memcpy(ptr, str, n);
*(((char *)ptr) + n) = '\0';