mirror of
https://github.com/reactos/wine.git
synced 2024-11-24 20:30:01 +00:00
localspl: Avoid using sizeof on structs with variable length array.
This commit is contained in:
parent
d1f2b8a809
commit
e67deeb8a1
@ -513,7 +513,6 @@ cleanup:
|
||||
static BOOL WINAPI localmon_OpenPortW(LPWSTR pName, PHANDLE phPort)
|
||||
{
|
||||
port_t * port;
|
||||
DWORD len;
|
||||
DWORD type;
|
||||
|
||||
TRACE("%s, %p)\n", debugstr_w(pName), phPort);
|
||||
@ -525,12 +524,11 @@ static BOOL WINAPI localmon_OpenPortW(LPWSTR pName, PHANDLE phPort)
|
||||
type = get_type_from_local_name(pName);
|
||||
if (!type) return FALSE;
|
||||
|
||||
len = (lstrlenW(pName) + 1) * sizeof(WCHAR);
|
||||
port = heap_alloc(sizeof(port_t) + len);
|
||||
port = heap_alloc(FIELD_OFFSET(port_t, nameW[lstrlenW(pName) + 1]));
|
||||
if (!port) return FALSE;
|
||||
|
||||
port->type = type;
|
||||
memcpy(port->nameW, pName, len);
|
||||
lstrcpyW(port->nameW, pName);
|
||||
*phPort = port;
|
||||
|
||||
EnterCriticalSection(&port_handles_cs);
|
||||
@ -734,16 +732,14 @@ static DWORD WINAPI localmon_XcvDataPort(HANDLE hXcv, LPCWSTR pszDataName, PBYTE
|
||||
*/
|
||||
static BOOL WINAPI localmon_XcvOpenPort(LPCWSTR pName, ACCESS_MASK GrantedAccess, PHANDLE phXcv)
|
||||
{
|
||||
DWORD len;
|
||||
xcv_t * xcv;
|
||||
|
||||
TRACE("%s, 0x%x, %p)\n", debugstr_w(pName), GrantedAccess, phXcv);
|
||||
/* No checks for any field is done in Windows */
|
||||
len = (lstrlenW(pName) + 1) * sizeof(WCHAR);
|
||||
xcv = heap_alloc( sizeof(xcv_t) + len);
|
||||
xcv = heap_alloc(FIELD_OFFSET(xcv_t, nameW[lstrlenW(pName) + 1]));
|
||||
if (xcv) {
|
||||
xcv->GrantedAccess = GrantedAccess;
|
||||
memcpy(xcv->nameW, pName, len);
|
||||
lstrcpyW(xcv->nameW, pName);
|
||||
*phXcv = xcv;
|
||||
EnterCriticalSection(&xcv_handles_cs);
|
||||
list_add_tail(&xcv_handles, &xcv->entry);
|
||||
|
Loading…
Reference in New Issue
Block a user