diff options
| -rw-r--r-- | src/util.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/util.h b/src/util.h index 18929af8e..f70bfe743 100644 --- a/src/util.h +++ b/src/util.h @@ -47,11 +47,13 @@ GIT_INLINE(char *) git__strndup(const char *str, size_t n) length = n; ptr = (char*)malloc(length + 1); - if (!ptr) + if (!ptr) { git__throw(GIT_ENOMEM, "Out of memory. Failed to duplicate string"); + return NULL; + } memcpy(ptr, str, length); - ptr[length] = 0; + ptr[length] = '\0'; return ptr; } |
