summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2013-08-08 12:36:11 -0500
committerEdward Thomson <ethomson@microsoft.com>2013-08-08 12:36:11 -0500
commita1f69452a22689ca2eede7669e79a3e7ab849cdd (patch)
treee3ba1d3b1ca69868d86c0d61ff5b02b4e0cf0c29
parent57f31f058c29edfd7d6d810fcd4a964875e9d463 (diff)
downloadlibgit2-a1f69452a22689ca2eede7669e79a3e7ab849cdd.tar.gz
git_strndup fix when OOM
-rw-r--r--src/util.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index ed9624770..a784390c1 100644
--- a/src/util.h
+++ b/src/util.h
@@ -55,6 +55,9 @@ GIT_INLINE(char *) git__strndup(const char *str, size_t n)
ptr = (char*)git__malloc(length + 1);
+ if (!ptr)
+ return NULL;
+
if (length)
memcpy(ptr, str, length);