Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
0393d43c
Commit
0393d43c
authored
Aug 28, 2002
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed WM_GETTEXT handling to avoid strncpy and return correct lengths.
parent
4a75c5c6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
64 deletions
+65
-64
combo.c
controls/combo.c
+65
-64
No files found.
controls/combo.c
View file @
0393d43c
...
...
@@ -1518,100 +1518,100 @@ static LRESULT COMBO_ItemOp( LPHEADCOMBO lphc, UINT msg, LPARAM lParam )
return
SendMessageW
(
lphc
->
owner
,
msg
,
id
,
lParam
);
}
/***********************************************************************
* COMBO_GetText
*
* NOTE! LB_GETTEXT does not count terminating \0, WM_GETTEXT does.
* also LB_GETTEXT might return values < 0, WM_GETTEXT doesn't.
* COMBO_GetTextW
*/
static
LRESULT
COMBO_GetText
(
LPHEADCOMBO
lphc
,
INT
N
,
LPARAM
lParam
,
BOOL
unicode
)
static
LRESULT
COMBO_GetText
W
(
LPHEADCOMBO
lphc
,
INT
count
,
LPWSTR
buf
)
{
INT
length
;
if
(
lphc
->
wState
&
CBF_EDIT
)
return
unicode
?
SendMessageW
(
lphc
->
hWndEdit
,
WM_GETTEXT
,
(
WPARAM
)
N
,
lParam
)
:
SendMessageA
(
lphc
->
hWndEdit
,
WM_GETTEXT
,
(
WPARAM
)
N
,
lParam
);
return
SendMessageW
(
lphc
->
hWndEdit
,
WM_GETTEXT
,
count
,
(
LPARAM
)
buf
);
/* get it from the listbox */
if
(
!
count
||
!
buf
)
return
0
;
if
(
lphc
->
hWndLBox
)
{
INT
idx
=
SendMessageW
(
lphc
->
hWndLBox
,
LB_GETCURSEL
,
0
,
0
);
if
(
idx
!=
LB_ERR
)
{
INT
n
=
0
;
INT
length
=
SendMessageW
(
lphc
->
hWndLBox
,
LB_GETTEXTLEN
,
(
WPARAM
)
idx
,
0
);
if
(
length
==
LB_ERR
)
FIXME
(
"LB_ERR probably not handled yet
\n
"
);
if
(
unicode
)
{
LPWSTR
lpBuffer
,
lpText
=
(
LPWSTR
)
lParam
;
if
(
idx
==
LB_ERR
)
goto
error
;
length
=
SendMessageW
(
lphc
->
hWndLBox
,
LB_GETTEXTLEN
,
idx
,
0
);
if
(
length
==
LB_ERR
)
goto
error
;
/* 'length' is without the terminating character */
if
(
length
>=
N
)
lpBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
length
+
1
)
*
sizeof
(
WCHAR
));
else
lpBuffer
=
lpText
;
if
(
lpBuffer
)
if
(
length
>=
count
)
{
n
=
SendMessageW
(
lphc
->
hWndLBox
,
LB_GETTEXT
,
(
WPARAM
)
idx
,
(
LPARAM
)
lpBuffer
);
LPWSTR
lpBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
length
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
lpBuffer
)
goto
error
;
length
=
SendMessageW
(
lphc
->
hWndLBox
,
LB_GETTEXT
,
idx
,
(
LPARAM
)
lpBuffer
);
/* truncate if buffer is too short */
if
(
length
>=
N
)
if
(
length
!=
LB_ERR
)
{
if
(
N
&&
lpText
)
{
if
(
n
!=
LB_ERR
)
strncpyW
(
lpText
,
lpBuffer
,
(
N
>
n
)
?
n
+
1
:
N
-
1
);
lpText
[
N
-
1
]
=
'\0'
;
lstrcpynW
(
buf
,
lpBuffer
,
count
);
length
=
count
;
}
HeapFree
(
GetProcessHeap
(),
0
,
lpBuffer
);
}
else
length
=
SendMessageW
(
lphc
->
hWndLBox
,
LB_GETTEXT
,
idx
,
(
LPARAM
)
buf
);
if
(
length
==
LB_ERR
)
return
0
;
return
length
;
}
}
else
error:
/* error - truncate string, return zero */
buf
[
0
]
=
0
;
return
0
;
}
/***********************************************************************
* COMBO_GetTextA
*
* NOTE! LB_GETTEXT does not count terminating \0, WM_GETTEXT does.
* also LB_GETTEXT might return values < 0, WM_GETTEXT doesn't.
*/
static
LRESULT
COMBO_GetTextA
(
LPHEADCOMBO
lphc
,
INT
count
,
LPSTR
buf
)
{
INT
length
;
if
(
lphc
->
wState
&
CBF_EDIT
)
return
SendMessageA
(
lphc
->
hWndEdit
,
WM_GETTEXT
,
count
,
(
LPARAM
)
buf
);
/* get it from the listbox */
if
(
!
count
||
!
buf
)
return
0
;
if
(
lphc
->
hWndLBox
)
{
LPSTR
lpBuffer
,
lpText
=
(
LPSTR
)
lParam
;
INT
idx
=
SendMessageA
(
lphc
->
hWndLBox
,
LB_GETCURSEL
,
0
,
0
);
if
(
idx
==
LB_ERR
)
goto
error
;
length
=
SendMessageA
(
lphc
->
hWndLBox
,
LB_GETTEXTLEN
,
idx
,
0
);
if
(
length
==
LB_ERR
)
goto
error
;
/* 'length' is without the terminating character */
if
(
length
>=
N
)
lpBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
length
+
1
);
else
lpBuffer
=
lpText
;
if
(
lpBuffer
)
if
(
length
>=
count
)
{
n
=
SendMessageA
(
lphc
->
hWndLBox
,
LB_GETTEXT
,
(
WPARAM
)
idx
,
(
LPARAM
)
lpBuffer
);
LPSTR
lpBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
length
+
1
)
);
if
(
!
lpBuffer
)
goto
error
;
length
=
SendMessageA
(
lphc
->
hWndLBox
,
LB_GETTEXT
,
idx
,
(
LPARAM
)
lpBuffer
);
/* truncate if buffer is too short */
if
(
length
>=
N
)
{
if
(
N
&&
lpText
)
if
(
length
!=
LB_ERR
)
{
if
(
n
!=
LB_ERR
)
strncpy
(
lpText
,
lpBuffer
,
(
N
>
n
)
?
n
+
1
:
N
-
1
);
lpText
[
N
-
1
]
=
'\0'
;
lstrcpynA
(
buf
,
lpBuffer
,
count
);
length
=
count
;
}
HeapFree
(
GetProcessHeap
(),
0
,
lpBuffer
);
}
else
length
=
SendMessageA
(
lphc
->
hWndLBox
,
LB_GETTEXT
,
idx
,
(
LPARAM
)
buf
);
if
(
length
==
LB_ERR
)
return
0
;
return
length
;
}
}
if
(
n
<
0
)
n
=
0
;
else
n
++
;
return
(
LRESULT
)
n
;
}
}
/* LB_GETCURSEL returned LB_ERR - truncate string, return zero */
if
(
unicode
)
{
LPWSTR
lpText
=
(
LPWSTR
)
lParam
;
lpText
[
0
]
=
'\0'
;
}
else
{
LPSTR
lpText
=
(
LPSTR
)
lParam
;
lpText
[
0
]
=
'\0'
;
}
error:
/* error - truncate string, return zero */
buf
[
0
]
=
0
;
return
0
;
}
...
...
@@ -1991,7 +1991,8 @@ static LRESULT ComboWndProc_common( HWND hwnd, UINT message,
case
WM_COMMAND
:
return
COMBO_Command
(
lphc
,
wParam
,
WIN_GetFullHandle
(
(
HWND
)
lParam
)
);
case
WM_GETTEXT
:
return
COMBO_GetText
(
lphc
,
(
INT
)
wParam
,
lParam
,
unicode
);
return
unicode
?
COMBO_GetTextW
(
lphc
,
wParam
,
(
LPWSTR
)
lParam
)
:
COMBO_GetTextA
(
lphc
,
wParam
,
(
LPSTR
)
lParam
);
case
WM_SETTEXT
:
case
WM_GETTEXTLENGTH
:
case
WM_CLEAR
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment