projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Another big batch of memory leak fixes, again mostly on error paths.
[u/mdw/putty]
/
windows
/
window.c
diff --git
a/windows/window.c
b/windows/window.c
index
38270e6
..
b477d6a
100644
(file)
--- a/
windows/window.c
+++ b/
windows/window.c
@@
-2197,8
+2197,10
@@
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
reconfig_result =
do_reconfig(hwnd, back ? back->cfg_info(backhandle) : 0);
reconfiguring = FALSE;
reconfig_result =
do_reconfig(hwnd, back ? back->cfg_info(backhandle) : 0);
reconfiguring = FALSE;
- if (!reconfig_result)
+ if (!reconfig_result) {
+ conf_free(prev_conf);
break;
break;
+ }
conf_cache_data();
conf_cache_data();
@@
-3905,8
+3907,7
@@
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
HKL kbd_layout = GetKeyboardLayout(0);
HKL kbd_layout = GetKeyboardLayout(0);
- /* keys is for ToAsciiEx. There's some ick here, see below. */
- static WORD keys[3];
+ static wchar_t keys_unicode[3];
static int compose_char = 0;
static WPARAM compose_keycode = 0;
static int compose_char = 0;
static WPARAM compose_keycode = 0;
@@
-3958,12
+3959,12
@@
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
else if (ch)
debug((", $%02x", ch));
else if (ch)
debug((", $%02x", ch));
- if (keys[0])
- debug((", KB0=%0
2x", keys
[0]));
- if (keys[1])
- debug((", KB1=%0
2x", keys
[1]));
- if (keys[2])
- debug((", KB2=%0
2x", keys
[2]));
+ if (keys
_unicode
[0])
+ debug((", KB0=%0
4x", keys_unicode
[0]));
+ if (keys
_unicode
[1])
+ debug((", KB1=%0
4x", keys_unicode
[1]));
+ if (keys
_unicode
[2])
+ debug((", KB2=%0
4x", keys_unicode
[2]));
if ((keystate[VK_SHIFT] & 0x80) != 0)
debug((", S"));
if ((keystate[VK_SHIFT] & 0x80) != 0)
debug((", S"));
@@
-4579,6
+4580,9
@@
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
* be is? There's indication on MS' website of an Inquire/InquireEx
* functioning returning a KBINFO structure which tells us. */
if (osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) {
* be is? There's indication on MS' website of an Inquire/InquireEx
* functioning returning a KBINFO structure which tells us. */
if (osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+ r = ToUnicodeEx(wParam, scan, keystate, keys_unicode,
+ lenof(keys_unicode), 0, kbd_layout);
+ } else {
/* XXX 'keys' parameter is declared in MSDN documentation as
* 'LPWORD lpChar'.
* The experience of a French user indicates that on
/* XXX 'keys' parameter is declared in MSDN documentation as
* 'LPWORD lpChar'.
* The experience of a French user indicates that on
@@
-4589,12
+4593,17
@@
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
* Win9x/NT split, but I suspect it's worse than that.
* See wishlist item `win-dead-keys' for more horrible detail
* and speculations. */
* Win9x/NT split, but I suspect it's worse than that.
* See wishlist item `win-dead-keys' for more horrible detail
* and speculations. */
- BYTE keybs[3];
int i;
int i;
- r = ToAsciiEx(wParam, scan, keystate, (LPWORD)keybs, 0, kbd_layout);
- for (i=0; i<3; i++) keys[i] = keybs[i];
- } else {
+ static WORD keys[3];
+ static BYTE keysb[3];
r = ToAsciiEx(wParam, scan, keystate, keys, 0, kbd_layout);
r = ToAsciiEx(wParam, scan, keystate, keys, 0, kbd_layout);
+ if (r > 0) {
+ for (i = 0; i < r; i++) {
+ keysb[i] = (BYTE)keys[i];
+ }
+ MultiByteToWideChar(CP_ACP, 0, (LPCSTR)keysb, r,
+ keys_unicode, lenof(keys_unicode));
+ }
}
#ifdef SHOW_TOASCII_RESULT
if (r == 1 && !key_down) {
}
#ifdef SHOW_TOASCII_RESULT
if (r == 1 && !key_down) {
@@
-4604,13
+4613,13
@@
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
else
debug((", LCH(%d)", alt_sum));
} else {
else
debug((", LCH(%d)", alt_sum));
} else {
- debug((", ACH(%d)", keys[0]));
+ debug((", ACH(%d)", keys
_unicode
[0]));
}
} else if (r > 0) {
int r1;
debug((", ASC("));
for (r1 = 0; r1 < r; r1++) {
}
} else if (r > 0) {
int r1;
debug((", ASC("));
for (r1 = 0; r1 < r; r1++) {
- debug(("%s%d", r1 ? "," : "", keys[r1]));
+ debug(("%s%d", r1 ? "," : "", keys
_unicode
[r1]));
}
debug((")"));
}
}
debug((")"));
}
@@
-4627,18
+4636,18
@@
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
p = output;
for (i = 0; i < r; i++) {
p = output;
for (i = 0; i < r; i++) {
-
unsigned char ch = (unsigned char) keys
[i];
+
wchar_t wch = keys_unicode
[i];
- if (compose_state == 2 &&
(ch & 0x80) == 0 && ch > ' '
) {
- compose_char = ch;
+ if (compose_state == 2 &&
wch >= ' ' && wch < 0x80
) {
+ compose_char =
w
ch;
compose_state++;
continue;
}
compose_state++;
continue;
}
- if (compose_state == 3 &&
(ch & 0x80) == 0 && ch > ' '
) {
+ if (compose_state == 3 &&
wch >= ' ' && wch < 0x80
) {
int nc;
compose_state = 0;
int nc;
compose_state = 0;
- if ((nc = check_compose(compose_char, ch)) == -1) {
+ if ((nc = check_compose(compose_char,
w
ch)) == -1) {
MessageBeep(MB_ICONHAND);
return 0;
}
MessageBeep(MB_ICONHAND);
return 0;
}
@@
-4659,7
+4668,7
@@
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
if (ldisc)
luni_send(ldisc, &keybuf, 1, 1);
} else {
if (ldisc)
luni_send(ldisc, &keybuf, 1, 1);
} else {
- ch = (char) alt_sum;
+ ch
ar ch
= (char) alt_sum;
/*
* We need not bother about stdin
* backlogs here, because in GUI PuTTY
/*
* We need not bother about stdin
* backlogs here, because in GUI PuTTY
@@
-4677,40
+4686,39
@@
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
} else {
term_seen_key_event(term);
if (ldisc)
} else {
term_seen_key_event(term);
if (ldisc)
- l
page_send(ldisc, kbd_codepage, &
ch, 1, 1);
+ l
uni_send(ldisc, &w
ch, 1, 1);
}
} else {
}
} else {
- if(capsOn && ch < 0x80) {
+ if(capsOn &&
w
ch < 0x80) {
WCHAR cbuf[2];
cbuf[0] = 27;
WCHAR cbuf[2];
cbuf[0] = 27;
- cbuf[1] = xlat_uskbd2cyrllic(ch);
+ cbuf[1] = xlat_uskbd2cyrllic(
w
ch);
term_seen_key_event(term);
if (ldisc)
luni_send(ldisc, cbuf+!left_alt, 1+!!left_alt, 1);
} else {
term_seen_key_event(term);
if (ldisc)
luni_send(ldisc, cbuf+!left_alt, 1+!!left_alt, 1);
} else {
-
char
cbuf[2];
+
WCHAR
cbuf[2];
cbuf[0] = '\033';
cbuf[0] = '\033';
- cbuf[1] = ch;
+ cbuf[1] =
w
ch;
term_seen_key_event(term);
if (ldisc)
term_seen_key_event(term);
if (ldisc)
- lpage_send(ldisc, kbd_codepage,
- cbuf+!left_alt, 1+!!left_alt, 1);
+ luni_send(ldisc, cbuf +!left_alt, 1+!!left_alt, 1);
}
}
show_mouseptr(0);
}
/* This is so the ALT-Numpad and dead keys work correctly. */
}
}
show_mouseptr(0);
}
/* This is so the ALT-Numpad and dead keys work correctly. */
- keys[0] = 0;
+ keys
_unicode
[0] = 0;
return p - output;
}
/* If we're definitly not building up an ALT-54321 then clear it */
if (!left_alt)
return p - output;
}
/* If we're definitly not building up an ALT-54321 then clear it */
if (!left_alt)
- keys[0] = 0;
+ keys
_unicode
[0] = 0;
/* If we will be using alt_sum fix the 256s */
/* If we will be using alt_sum fix the 256s */
- else if (keys[0] && (in_utf(term) || ucsdata.dbcs_screenfont))
- keys[0] = 10;
+ else if (keys
_unicode
[0] && (in_utf(term) || ucsdata.dbcs_screenfont))
+ keys
_unicode
[0] = 10;
}
/*
}
/*
@@
-4897,10
+4905,17
@@
void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_des
GlobalFree(clipdata2);
return;
}
GlobalFree(clipdata2);
return;
}
- if (!(lock = GlobalLock(clipdata)))
+ if (!(lock = GlobalLock(clipdata))) {
+ GlobalFree(clipdata);
+ GlobalFree(clipdata2);
return;
return;
- if (!(lock2 = GlobalLock(clipdata2)))
+ }
+ if (!(lock2 = GlobalLock(clipdata2))) {
+ GlobalUnlock(clipdata);
+ GlobalFree(clipdata);
+ GlobalFree(clipdata2);
return;
return;
+ }
memcpy(lock, data, len * sizeof(wchar_t));
WideCharToMultiByte(CP_ACP, 0, data, len, lock2, len2, NULL, NULL);
memcpy(lock, data, len * sizeof(wchar_t));
WideCharToMultiByte(CP_ACP, 0, data, len, lock2, len2, NULL, NULL);