diff options
author | Sven Strickroth <email@cs-ware.de> | 2013-02-01 22:14:52 +0100 |
---|---|---|
committer | Sven Strickroth <email@cs-ware.de> | 2013-02-01 22:17:34 +0100 |
commit | 89ad1c57a351809d3173e22a26c84e7a16adbe6b (patch) | |
tree | 4fa5cf372349b21878bb8da9beda4ae0b1181ce7 /src/errors.c | |
parent | b0dc81f055d4eb523c92bc859d5641e72d343b00 (diff) | |
download | libgit2-89ad1c57a351809d3173e22a26c84e7a16adbe6b.tar.gz |
Get utf8_size from WideCharToMultiByte instead of guessing it
Signed-off-by: Sven Strickroth <email@cs-ware.de>
Diffstat (limited to 'src/errors.c')
-rw-r--r-- | src/errors.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/errors.c b/src/errors.c index c64db7b85..1ab2894ed 100644 --- a/src/errors.c +++ b/src/errors.c @@ -61,11 +61,11 @@ void giterr_set(int error_class, const char *string, ...) (LPWSTR)&lpMsgBuf, 0, NULL); if (size) { - int utf8_size = size * 4 + 1; + int utf8_size = WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, -1, NULL, 0, NULL, NULL); - char *lpMsgBuf_utf8 = git__calloc(utf8_size, sizeof(char)); + char *lpMsgBuf_utf8 = git__malloc(utf8_size * sizeof(char)); GITERR_CHECK_ALLOC(lpMsgBuf_utf8); - WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, size, lpMsgBuf_utf8, utf8_size, NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, -1, lpMsgBuf_utf8, utf8_size, NULL, NULL); git_buf_PUTS(&buf, ": "); git_buf_puts(&buf, lpMsgBuf_utf8); |