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
4da23207
Commit
4da23207
authored
Jul 19, 2012
by
Jacek Caban
Committed by
Alexandre Julliard
Jul 19, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32: Use proper allocators for storing help file in ErrorInfoImpl.
parent
cd1f67ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
89 deletions
+7
-89
errorinfo.c
dlls/ole32/errorinfo.c
+7
-89
No files found.
dlls/ole32/errorinfo.c
View file @
4da23207
...
@@ -67,86 +67,6 @@ static inline WCHAR *heap_strdupW(const WCHAR *str)
...
@@ -67,86 +67,6 @@ static inline WCHAR *heap_strdupW(const WCHAR *str)
return
ret
;
return
ret
;
}
}
/* this code is from SysAllocStringLen (ole2disp.c in oleaut32) */
static
BSTR
ERRORINFO_SysAllocString
(
const
OLECHAR
*
in
)
{
DWORD
bufferSize
;
DWORD
*
newBuffer
;
WCHAR
*
stringBuffer
;
DWORD
len
;
if
(
in
==
NULL
)
return
NULL
;
/*
* Find the length of the buffer passed-in, in bytes.
*/
len
=
strlenW
(
in
);
bufferSize
=
len
*
sizeof
(
WCHAR
);
/*
* Allocate a new buffer to hold the string.
* don't forget to keep an empty spot at the beginning of the
* buffer for the character count and an extra character at the
* end for the '\0'.
*/
newBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
bufferSize
+
sizeof
(
WCHAR
)
+
sizeof
(
DWORD
));
/*
* If the memory allocation failed, return a null pointer.
*/
if
(
newBuffer
==
0
)
return
0
;
/*
* Copy the length of the string in the placeholder.
*/
*
newBuffer
=
bufferSize
;
/*
* Skip the byte count.
*/
newBuffer
++
;
/*
* Copy the information in the buffer. It is not possible to pass
* a NULL pointer here.
*/
memcpy
(
newBuffer
,
in
,
bufferSize
);
/*
* Make sure that there is a nul character at the end of the
* string.
*/
stringBuffer
=
(
WCHAR
*
)
newBuffer
;
stringBuffer
[
len
]
=
0
;
return
stringBuffer
;
}
/* this code is from SysFreeString (ole2disp.c in oleaut32)*/
static
VOID
ERRORINFO_SysFreeString
(
BSTR
in
)
{
DWORD
*
bufferPointer
;
/* NULL is a valid parameter */
if
(
!
in
)
return
;
/*
* We have to be careful when we free a BSTR pointer, it points to
* the beginning of the string but it skips the byte count contained
* before the string.
*/
bufferPointer
=
(
DWORD
*
)
in
;
bufferPointer
--
;
/*
* Free the memory from it's "real" origin.
*/
HeapFree
(
GetProcessHeap
(),
0
,
bufferPointer
);
}
typedef
struct
ErrorInfoImpl
typedef
struct
ErrorInfoImpl
{
{
IErrorInfo
IErrorInfo_iface
;
IErrorInfo
IErrorInfo_iface
;
...
@@ -157,7 +77,7 @@ typedef struct ErrorInfoImpl
...
@@ -157,7 +77,7 @@ typedef struct ErrorInfoImpl
GUID
m_Guid
;
GUID
m_Guid
;
WCHAR
*
source
;
WCHAR
*
source
;
WCHAR
*
description
;
WCHAR
*
description
;
BSTR
bstrHelpF
ile
;
WCHAR
*
help_f
ile
;
DWORD
m_dwHelpContext
;
DWORD
m_dwHelpContext
;
}
ErrorInfoImpl
;
}
ErrorInfoImpl
;
...
@@ -231,9 +151,8 @@ static ULONG WINAPI IErrorInfoImpl_Release(
...
@@ -231,9 +151,8 @@ static ULONG WINAPI IErrorInfoImpl_Release(
heap_free
(
This
->
source
);
heap_free
(
This
->
source
);
heap_free
(
This
->
description
);
heap_free
(
This
->
description
);
ERRORINFO_SysFreeString
(
This
->
bstrHelpFile
);
heap_free
(
This
->
help_file
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
heap_free
(
This
);
return
0
;
}
}
return
ref
;
return
ref
;
}
}
...
@@ -284,7 +203,7 @@ static HRESULT WINAPI IErrorInfoImpl_GetHelpFile(
...
@@ -284,7 +203,7 @@ static HRESULT WINAPI IErrorInfoImpl_GetHelpFile(
TRACE
(
"(%p)->(pBstrHelpFile=%p)
\n
"
,
This
,
pBstrHelpFile
);
TRACE
(
"(%p)->(pBstrHelpFile=%p)
\n
"
,
This
,
pBstrHelpFile
);
if
(
pBstrHelpFile
==
NULL
)
if
(
pBstrHelpFile
==
NULL
)
return
E_INVALIDARG
;
return
E_INVALIDARG
;
*
pBstrHelpFile
=
ERRORINFO_SysAllocString
(
This
->
bstrHelpF
ile
);
*
pBstrHelpFile
=
SysAllocString
(
This
->
help_f
ile
);
return
S_OK
;
return
S_OK
;
}
}
...
@@ -380,9 +299,8 @@ static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpFile(
...
@@ -380,9 +299,8 @@ static HRESULT WINAPI ICreateErrorInfoImpl_SetHelpFile(
{
{
ErrorInfoImpl
*
This
=
impl_from_ICreateErrorInfo
(
iface
);
ErrorInfoImpl
*
This
=
impl_from_ICreateErrorInfo
(
iface
);
TRACE
(
"(%p,%s)
\n
"
,
This
,
debugstr_w
(
szHelpFile
));
TRACE
(
"(%p,%s)
\n
"
,
This
,
debugstr_w
(
szHelpFile
));
if
(
This
->
bstrHelpFile
!=
NULL
)
heap_free
(
This
->
help_file
);
ERRORINFO_SysFreeString
(
This
->
bstrHelpFile
);
This
->
help_file
=
heap_strdupW
(
szHelpFile
);
This
->
bstrHelpFile
=
ERRORINFO_SysAllocString
(
szHelpFile
);
return
S_OK
;
return
S_OK
;
}
}
...
@@ -458,7 +376,7 @@ static IErrorInfo* IErrorInfoImpl_Constructor(void)
...
@@ -458,7 +376,7 @@ static IErrorInfo* IErrorInfoImpl_Constructor(void)
This
->
ref
=
1
;
This
->
ref
=
1
;
This
->
source
=
NULL
;
This
->
source
=
NULL
;
This
->
description
=
NULL
;
This
->
description
=
NULL
;
This
->
bstrHelpF
ile
=
NULL
;
This
->
help_f
ile
=
NULL
;
This
->
m_dwHelpContext
=
0
;
This
->
m_dwHelpContext
=
0
;
return
&
This
->
IErrorInfo_iface
;
return
&
This
->
IErrorInfo_iface
;
...
...
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