git_strndup fix when OOM

This commit is contained in:
Edward Thomson 2013-08-08 12:36:11 -05:00
parent 57f31f058c
commit a1f69452a2

View File

@ -55,6 +55,9 @@ GIT_INLINE(char *) git__strndup(const char *str, size_t n)
ptr = (char*)git__malloc(length + 1); ptr = (char*)git__malloc(length + 1);
if (!ptr)
return NULL;
if (length) if (length)
memcpy(ptr, str, length); memcpy(ptr, str, length);