aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGuenter Knauf <lists@gknw.net>2011-04-19 17:13:09 +0200
committerGuenter Knauf <lists@gknw.net>2011-04-19 17:13:09 +0200
commit519bec7c916d2062249838d42a20ed7fb6ed9119 (patch)
tree799cbe2388698328f00452cd1518adc0bdd3db18 /lib
parent24e5a40156b0dda012d3ff940a49d9fef4524bdc (diff)
Windows native IDN fixes.
changed windows.h include to system header; changed obsolete 2nd check for str_w to str_utf8 in order to catch malloc() failure and avoid a free(NULL); changed calls to GetLastError() to void to kill unsused var compiler warnings; moved one call to GetLastError() into else case so that its only called when WideCharToMultiByte() really fails.
Diffstat (limited to 'lib')
-rw-r--r--lib/idn_win32.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/idn_win32.c b/lib/idn_win32.c
index 41fdd5dbb..f2df51675 100644
--- a/lib/idn_win32.c
+++ b/lib/idn_win32.c
@@ -24,7 +24,13 @@
* Pierre Joye <pierre@php.net>
***************************************************************************/
#if defined(WIN32) && defined(USE_WIN32_IDN)
-#include "windows.h"
+#include <windows.h>
+#ifdef HAVE_NORMALIZATION_H
+#define __in
+#define __in_ecount(x)
+#define __out_ecount(x)
+#include <normalization.h>
+#endif
#include <stdio.h>
#include <tchar.h>
#define IDN_MAX_LENGTH 255
@@ -58,18 +64,20 @@ static const char *_curl_win32_wchar_to_UTF8(const wchar_t *str_w)
if (str_w) {
size_t str_utf8_len = WideCharToMultiByte(CP_UTF8, 0, str_w, -1, NULL,
0, NULL, NULL);
- DWORD err = GetLastError();
if (str_utf8_len) {
str_utf8 = (char *) malloc(str_utf8_len * sizeof(wchar_t));
- if (str_w) {
+ if (str_utf8) {
if (WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, str_utf8_len,
NULL, FALSE) == 0) {
- DWORD err = GetLastError();
+ (void) GetLastError();
free((void *)str_utf8);
str_utf8 = NULL;
}
}
}
+ else {
+ (void) GetLastError();
+ }
}
return str_utf8;