diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2015-02-10 23:13:49 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2015-02-12 22:54:47 -0500 |
| commit | 3603cb0978b7ef21ff9cd63693ebd6d27bc2bc53 (patch) | |
| tree | 20f97cffa9b4f44d3ab90bc1686a64d57223a322 /src/win32/utf-conv.c | |
| parent | 15d54fdd345dadc2854200ce5b9aad0949e3949b (diff) | |
| download | libgit2-3603cb0978b7ef21ff9cd63693ebd6d27bc2bc53.tar.gz | |
git__*allocarray: safer realloc and malloc
Introduce git__reallocarray that checks the product of the number
of elements and element size for overflow before allocation. Also
introduce git__mallocarray that behaves like calloc, but without the
`c`. (It does not zero memory, for those truly worried about every
cycle.)
Diffstat (limited to 'src/win32/utf-conv.c')
| -rw-r--r-- | src/win32/utf-conv.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/win32/utf-conv.c b/src/win32/utf-conv.c index 624611205..0dad4eab0 100644 --- a/src/win32/utf-conv.c +++ b/src/win32/utf-conv.c @@ -99,8 +99,7 @@ int git__utf8_to_16_alloc(wchar_t **dest, const char *src) return -1; } - if (GIT_ALLOC_OVERFLOW_MULTIPLY(utf16_size, sizeof(wchar_t)) || - !(*dest = git__malloc(utf16_size * sizeof(wchar_t)))) { + if (!(*dest = git__mallocarray(utf16_size, sizeof(wchar_t)))) { errno = ENOMEM; return -1; } |
