summaryrefslogtreecommitdiff
path: root/src/errors.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/errors.c')
-rw-r--r--src/errors.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/errors.c b/src/errors.c
index 1ab2894ed..56f07b624 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -64,8 +64,15 @@ void giterr_set(int error_class, const char *string, ...)
int utf8_size = WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, -1, NULL, 0, NULL, NULL);
char *lpMsgBuf_utf8 = git__malloc(utf8_size * sizeof(char));
- GITERR_CHECK_ALLOC(lpMsgBuf_utf8);
- WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, -1, lpMsgBuf_utf8, utf8_size, NULL, NULL);
+ if (lpMsgBuf_utf8 == NULL) {
+ LocalFree(lpMsgBuf);
+ return;
+ }
+ if (!WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, -1, lpMsgBuf_utf8, utf8_size, NULL, NULL)) {
+ LocalFree(lpMsgBuf);
+ git__free(lpMsgBuf_utf8);
+ return;
+ }
git_buf_PUTS(&buf, ": ");
git_buf_puts(&buf, lpMsgBuf_utf8);