]> git.proxmox.com Git - libgit2.git/commitdiff
git_strndup fix when OOM
authorEdward Thomson <ethomson@microsoft.com>
Thu, 8 Aug 2013 17:36:11 +0000 (12:36 -0500)
committerEdward Thomson <ethomson@microsoft.com>
Thu, 8 Aug 2013 17:36:11 +0000 (12:36 -0500)
src/util.h

index ed962477002099d99435e3ffc132f88d008d0c82..a784390c174b663d4170bd3b7dd1602fd09568c7 100644 (file)
@@ -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);