Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Strickroth <email@cs-ware.de>2013-02-02 01:14:52 +0400
committerSven Strickroth <email@cs-ware.de>2013-02-02 01:17:34 +0400
commit89ad1c57a351809d3173e22a26c84e7a16adbe6b (patch)
tree4fa5cf372349b21878bb8da9beda4ae0b1181ce7 /src/netops.c
parentb0dc81f055d4eb523c92bc859d5641e72d343b00 (diff)
Get utf8_size from WideCharToMultiByte instead of guessing it
Signed-off-by: Sven Strickroth <email@cs-ware.de>
Diffstat (limited to 'src/netops.c')
-rw-r--r--src/netops.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/netops.c b/src/netops.c
index 851ed4219..c5554ef86 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -46,10 +46,10 @@ static void net_set_error(const char *str)
int size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
0, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&err_str, 0, 0);
- int utf8_size = size * 4 + 1;
- char * err_str_utf8 = git__calloc(utf8_size, sizeof(char));
+ int utf8_size = WideCharToMultiByte(CP_UTF8, 0, err_str, -1, NULL, 0, NULL, NULL);
+ char * err_str_utf8 = git__malloc(utf8_size * sizeof(char));
GITERR_CHECK_ALLOC(err_str_utf8);
- WideCharToMultiByte(CP_UTF8, 0, err_str, size, err_str_utf8, utf8_size, NULL, NULL);
+ WideCharToMultiByte(CP_UTF8, 0, err_str, -1, err_str_utf8, utf8_size, NULL, NULL);
giterr_set(GITERR_NET, "%s: %s", str, err_str_utf8);
LocalFree(err_str);