Commit e67deeb8 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

localspl: Avoid using sizeof on structs with variable length array.

parent d1f2b8a8
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment