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
d886eda2
Commit
d886eda2
authored
Feb 02, 2018
by
Nikolay Sivov
Committed by
Alexandre Julliard
Feb 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comctl32/treeview: Use HeapAlloc() wrappers.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
db261c31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
26 deletions
+25
-26
treeview.c
dlls/comctl32/treeview.c
+25
-26
No files found.
dlls/comctl32/treeview.c
View file @
d886eda2
...
@@ -64,6 +64,7 @@
...
@@ -64,6 +64,7 @@
#include "wine/unicode.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/debug.h"
#include "wine/exception.h"
#include "wine/exception.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
treeview
);
WINE_DEFAULT_DEBUG_CHANNEL
(
treeview
);
...
@@ -552,7 +553,7 @@ TREEVIEW_TVItemFromItem(const TREEVIEW_INFO *infoPtr, UINT mask, TVITEMW *tvItem
...
@@ -552,7 +553,7 @@ TREEVIEW_TVItemFromItem(const TREEVIEW_INFO *infoPtr, UINT mask, TVITEMW *tvItem
if
(
!
infoPtr
->
bNtfUnicode
)
if
(
!
infoPtr
->
bNtfUnicode
)
{
{
tvItem
->
cchTextMax
=
WideCharToMultiByte
(
CP_ACP
,
0
,
item
->
pszText
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
tvItem
->
cchTextMax
=
WideCharToMultiByte
(
CP_ACP
,
0
,
item
->
pszText
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
tvItem
->
pszText
=
A
lloc
(
tvItem
->
cchTextMax
);
tvItem
->
pszText
=
heap_a
lloc
(
tvItem
->
cchTextMax
);
WideCharToMultiByte
(
CP_ACP
,
0
,
item
->
pszText
,
-
1
,
(
LPSTR
)
tvItem
->
pszText
,
tvItem
->
cchTextMax
,
0
,
0
);
WideCharToMultiByte
(
CP_ACP
,
0
,
item
->
pszText
,
-
1
,
(
LPSTR
)
tvItem
->
pszText
,
tvItem
->
cchTextMax
,
0
,
0
);
}
}
else
else
...
@@ -593,8 +594,8 @@ TREEVIEW_SendTreeviewNotify(const TREEVIEW_INFO *infoPtr, UINT code, UINT action
...
@@ -593,8 +594,8 @@ TREEVIEW_SendTreeviewNotify(const TREEVIEW_INFO *infoPtr, UINT code, UINT action
ret
=
TREEVIEW_SendRealNotify
(
infoPtr
,
code
,
&
nmhdr
.
hdr
);
ret
=
TREEVIEW_SendRealNotify
(
infoPtr
,
code
,
&
nmhdr
.
hdr
);
if
(
!
infoPtr
->
bNtfUnicode
)
if
(
!
infoPtr
->
bNtfUnicode
)
{
{
F
ree
(
nmhdr
.
itemOld
.
pszText
);
heap_f
ree
(
nmhdr
.
itemOld
.
pszText
);
F
ree
(
nmhdr
.
itemNew
.
pszText
);
heap_f
ree
(
nmhdr
.
itemNew
.
pszText
);
}
}
return
ret
;
return
ret
;
}
}
...
@@ -693,7 +694,7 @@ TREEVIEW_BeginLabelEditNotify(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *editI
...
@@ -693,7 +694,7 @@ TREEVIEW_BeginLabelEditNotify(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *editI
ret
=
TREEVIEW_SendRealNotify
(
infoPtr
,
TVN_BEGINLABELEDITW
,
&
tvdi
.
hdr
);
ret
=
TREEVIEW_SendRealNotify
(
infoPtr
,
TVN_BEGINLABELEDITW
,
&
tvdi
.
hdr
);
if
(
!
infoPtr
->
bNtfUnicode
)
if
(
!
infoPtr
->
bNtfUnicode
)
F
ree
(
tvdi
.
item
.
pszText
);
heap_f
ree
(
tvdi
.
item
.
pszText
);
return
ret
;
return
ret
;
}
}
...
@@ -739,7 +740,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
...
@@ -739,7 +740,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
(
LPSTR
)
callback
.
item
.
pszText
,
-
1
,
(
LPSTR
)
callback
.
item
.
pszText
,
-
1
,
NULL
,
0
);
NULL
,
0
);
buflen
=
max
((
len
)
*
sizeof
(
WCHAR
),
TEXT_CALLBACK_SIZE
);
buflen
=
max
((
len
)
*
sizeof
(
WCHAR
),
TEXT_CALLBACK_SIZE
);
newText
=
ReA
lloc
(
item
->
pszText
,
buflen
);
newText
=
heap_rea
lloc
(
item
->
pszText
,
buflen
);
TRACE
(
"returned str %s, len=%d, buflen=%d
\n
"
,
TRACE
(
"returned str %s, len=%d, buflen=%d
\n
"
,
debugstr_a
((
LPSTR
)
callback
.
item
.
pszText
),
len
,
buflen
);
debugstr_a
((
LPSTR
)
callback
.
item
.
pszText
),
len
,
buflen
);
...
@@ -752,12 +753,12 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
...
@@ -752,12 +753,12 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
item
->
pszText
,
buflen
/
sizeof
(
WCHAR
));
item
->
pszText
,
buflen
/
sizeof
(
WCHAR
));
item
->
cchTextMax
=
buflen
/
sizeof
(
WCHAR
);
item
->
cchTextMax
=
buflen
/
sizeof
(
WCHAR
);
}
}
/* If
ReA
lloc fails we have nothing to do, but keep original text */
/* If
rea
lloc fails we have nothing to do, but keep original text */
}
}
else
{
else
{
int
len
=
max
(
lstrlenW
(
callback
.
item
.
pszText
)
+
1
,
int
len
=
max
(
lstrlenW
(
callback
.
item
.
pszText
)
+
1
,
TEXT_CALLBACK_SIZE
);
TEXT_CALLBACK_SIZE
);
LPWSTR
newText
=
ReA
lloc
(
item
->
pszText
,
len
);
LPWSTR
newText
=
heap_rea
lloc
(
item
->
pszText
,
len
);
TRACE
(
"returned wstr %s, len=%d
\n
"
,
TRACE
(
"returned wstr %s, len=%d
\n
"
,
debugstr_w
(
callback
.
item
.
pszText
),
len
);
debugstr_w
(
callback
.
item
.
pszText
),
len
);
...
@@ -768,7 +769,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
...
@@ -768,7 +769,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
strcpyW
(
item
->
pszText
,
callback
.
item
.
pszText
);
strcpyW
(
item
->
pszText
,
callback
.
item
.
pszText
);
item
->
cchTextMax
=
len
;
item
->
cchTextMax
=
len
;
}
}
/* If
ReA
lloc fails we have nothing to do, but keep original text */
/* If
rea
lloc fails we have nothing to do, but keep original text */
}
}
}
}
else
if
(
mask
&
TVIF_TEXT
)
{
else
if
(
mask
&
TVIF_TEXT
)
{
...
@@ -780,7 +781,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
...
@@ -780,7 +781,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
(
LPSTR
)
callback
.
item
.
pszText
,
-
1
,
(
LPSTR
)
callback
.
item
.
pszText
,
-
1
,
NULL
,
0
);
NULL
,
0
);
buflen
=
max
((
len
)
*
sizeof
(
WCHAR
),
TEXT_CALLBACK_SIZE
);
buflen
=
max
((
len
)
*
sizeof
(
WCHAR
),
TEXT_CALLBACK_SIZE
);
newText
=
A
lloc
(
buflen
);
newText
=
heap_a
lloc
(
buflen
);
TRACE
(
"same buffer str %s, len=%d, buflen=%d
\n
"
,
TRACE
(
"same buffer str %s, len=%d, buflen=%d
\n
"
,
debugstr_a
((
LPSTR
)
callback
.
item
.
pszText
),
len
,
buflen
);
debugstr_a
((
LPSTR
)
callback
.
item
.
pszText
),
len
,
buflen
);
...
@@ -793,7 +794,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
...
@@ -793,7 +794,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
(
LPSTR
)
callback
.
item
.
pszText
,
-
1
,
(
LPSTR
)
callback
.
item
.
pszText
,
-
1
,
item
->
pszText
,
buflen
/
sizeof
(
WCHAR
));
item
->
pszText
,
buflen
/
sizeof
(
WCHAR
));
item
->
cchTextMax
=
buflen
/
sizeof
(
WCHAR
);
item
->
cchTextMax
=
buflen
/
sizeof
(
WCHAR
);
F
ree
(
oldText
);
heap_f
ree
(
oldText
);
}
}
}
}
}
}
...
@@ -1001,7 +1002,7 @@ TREEVIEW_UpdateSubTree(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *root)
...
@@ -1001,7 +1002,7 @@ TREEVIEW_UpdateSubTree(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *root)
static
TREEVIEW_ITEM
*
static
TREEVIEW_ITEM
*
TREEVIEW_AllocateItem
(
const
TREEVIEW_INFO
*
infoPtr
)
TREEVIEW_AllocateItem
(
const
TREEVIEW_INFO
*
infoPtr
)
{
{
TREEVIEW_ITEM
*
newItem
=
Alloc
(
sizeof
(
TREEVIEW_ITEM
));
TREEVIEW_ITEM
*
newItem
=
heap_alloc_zero
(
sizeof
(
*
newItem
));
if
(
!
newItem
)
if
(
!
newItem
)
return
NULL
;
return
NULL
;
...
@@ -1017,8 +1018,8 @@ TREEVIEW_AllocateItem(const TREEVIEW_INFO *infoPtr)
...
@@ -1017,8 +1018,8 @@ TREEVIEW_AllocateItem(const TREEVIEW_INFO *infoPtr)
if
(
DPA_InsertPtr
(
infoPtr
->
items
,
INT_MAX
,
newItem
)
==
-
1
)
if
(
DPA_InsertPtr
(
infoPtr
->
items
,
INT_MAX
,
newItem
)
==
-
1
)
{
{
F
ree
(
newItem
);
heap_f
ree
(
newItem
);
return
NULL
;
return
NULL
;
}
}
return
newItem
;
return
newItem
;
...
@@ -1042,7 +1043,7 @@ TREEVIEW_FreeItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
...
@@ -1042,7 +1043,7 @@ TREEVIEW_FreeItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
infoPtr
->
dropItem
=
NULL
;
infoPtr
->
dropItem
=
NULL
;
if
(
infoPtr
->
insertMarkItem
==
item
)
if
(
infoPtr
->
insertMarkItem
==
item
)
infoPtr
->
insertMarkItem
=
NULL
;
infoPtr
->
insertMarkItem
=
NULL
;
F
ree
(
item
);
heap_f
ree
(
item
);
}
}
...
@@ -1133,7 +1134,7 @@ TREEVIEW_DoSetItemT(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
...
@@ -1133,7 +1134,7 @@ TREEVIEW_DoSetItemT(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
else
else
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
tvItem
->
pszText
,
-
1
,
NULL
,
0
);
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
tvItem
->
pszText
,
-
1
,
NULL
,
0
);
newText
=
ReA
lloc
(
item
->
pszText
,
len
*
sizeof
(
WCHAR
));
newText
=
heap_rea
lloc
(
item
->
pszText
,
len
*
sizeof
(
WCHAR
));
if
(
newText
==
NULL
)
return
FALSE
;
if
(
newText
==
NULL
)
return
FALSE
;
...
@@ -1151,10 +1152,8 @@ TREEVIEW_DoSetItemT(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
...
@@ -1151,10 +1152,8 @@ TREEVIEW_DoSetItemT(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
}
}
else
else
{
{
callbackSet
|=
TVIF_TEXT
;
callbackSet
|=
TVIF_TEXT
;
item
->
pszText
=
heap_realloc
(
item
->
pszText
,
TEXT_CALLBACK_SIZE
*
sizeof
(
WCHAR
));
item
->
pszText
=
ReAlloc
(
item
->
pszText
,
TEXT_CALLBACK_SIZE
*
sizeof
(
WCHAR
));
item
->
cchTextMax
=
TEXT_CALLBACK_SIZE
;
item
->
cchTextMax
=
TEXT_CALLBACK_SIZE
;
TRACE
(
"setting callback, item %p
\n
"
,
item
);
TRACE
(
"setting callback, item %p
\n
"
,
item
);
}
}
...
@@ -1499,7 +1498,7 @@ TREEVIEW_RemoveItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
...
@@ -1499,7 +1498,7 @@ TREEVIEW_RemoveItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
infoPtr
->
uNumItems
--
;
infoPtr
->
uNumItems
--
;
if
(
item
->
pszText
!=
LPSTR_TEXTCALLBACKW
)
if
(
item
->
pszText
!=
LPSTR_TEXTCALLBACKW
)
F
ree
(
item
->
pszText
);
heap_f
ree
(
item
->
pszText
);
TREEVIEW_FreeItem
(
infoPtr
,
item
);
TREEVIEW_FreeItem
(
infoPtr
,
item
);
}
}
...
@@ -4031,18 +4030,18 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel)
...
@@ -4031,18 +4030,18 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel)
if
(
!
infoPtr
->
bNtfUnicode
)
if
(
!
infoPtr
->
bNtfUnicode
)
{
{
DWORD
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
tmpText
,
-
1
,
NULL
,
0
);
DWORD
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
tmpText
,
-
1
,
NULL
,
0
);
newText
=
A
lloc
(
len
*
sizeof
(
WCHAR
));
newText
=
heap_a
lloc
(
len
*
sizeof
(
WCHAR
));
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
tmpText
,
-
1
,
newText
,
len
);
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
tmpText
,
-
1
,
newText
,
len
);
iLength
=
len
-
1
;
iLength
=
len
-
1
;
}
}
if
(
strcmpW
(
newText
,
editedItem
->
pszText
)
!=
0
)
if
(
strcmpW
(
newText
,
editedItem
->
pszText
)
!=
0
)
{
{
WCHAR
*
ptr
=
ReA
lloc
(
editedItem
->
pszText
,
sizeof
(
WCHAR
)
*
(
iLength
+
1
));
WCHAR
*
ptr
=
heap_rea
lloc
(
editedItem
->
pszText
,
sizeof
(
WCHAR
)
*
(
iLength
+
1
));
if
(
ptr
==
NULL
)
if
(
ptr
==
NULL
)
{
{
ERR
(
"OutOfMemory, cannot allocate space for label
\n
"
);
ERR
(
"OutOfMemory, cannot allocate space for label
\n
"
);
if
(
newText
!=
tmpText
)
F
ree
(
newText
);
if
(
newText
!=
tmpText
)
heap_f
ree
(
newText
);
DestroyWindow
(
infoPtr
->
hwndEdit
);
DestroyWindow
(
infoPtr
->
hwndEdit
);
infoPtr
->
hwndEdit
=
0
;
infoPtr
->
hwndEdit
=
0
;
infoPtr
->
editItem
=
NULL
;
infoPtr
->
editItem
=
NULL
;
...
@@ -4056,7 +4055,7 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel)
...
@@ -4056,7 +4055,7 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel)
TREEVIEW_ComputeTextWidth
(
infoPtr
,
editedItem
,
0
);
TREEVIEW_ComputeTextWidth
(
infoPtr
,
editedItem
,
0
);
}
}
}
}
if
(
newText
!=
tmpText
)
F
ree
(
newText
);
if
(
newText
!=
tmpText
)
heap_f
ree
(
newText
);
}
}
ShowWindow
(
infoPtr
->
hwndEdit
,
SW_HIDE
);
ShowWindow
(
infoPtr
->
hwndEdit
,
SW_HIDE
);
...
@@ -5078,7 +5077,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
...
@@ -5078,7 +5077,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
TRACE
(
"wnd %p, style 0x%x
\n
"
,
hwnd
,
GetWindowLongW
(
hwnd
,
GWL_STYLE
));
TRACE
(
"wnd %p, style 0x%x
\n
"
,
hwnd
,
GetWindowLongW
(
hwnd
,
GWL_STYLE
));
infoPtr
=
Alloc
(
sizeof
(
TREEVIEW_INFO
));
infoPtr
=
heap_alloc_zero
(
sizeof
(
TREEVIEW_INFO
));
if
(
infoPtr
==
NULL
)
if
(
infoPtr
==
NULL
)
{
{
...
@@ -5203,7 +5202,7 @@ TREEVIEW_Destroy(TREEVIEW_INFO *infoPtr)
...
@@ -5203,7 +5202,7 @@ TREEVIEW_Destroy(TREEVIEW_INFO *infoPtr)
DeleteObject
(
infoPtr
->
hUnderlineFont
);
DeleteObject
(
infoPtr
->
hUnderlineFont
);
DeleteObject
(
infoPtr
->
hBoldUnderlineFont
);
DeleteObject
(
infoPtr
->
hBoldUnderlineFont
);
DestroyWindow
(
infoPtr
->
hwndToolTip
);
DestroyWindow
(
infoPtr
->
hwndToolTip
);
F
ree
(
infoPtr
);
heap_f
ree
(
infoPtr
);
return
0
;
return
0
;
}
}
...
...
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