shell32: Fix setting of NULL arguments in IShellLink.

This commit is contained in:
Alexandre Julliard 2009-11-16 20:09:48 +01:00
parent d51b4e19fb
commit 61a4200162
2 changed files with 31 additions and 8 deletions

View File

@ -1497,9 +1497,13 @@ static HRESULT WINAPI IShellLinkA_fnSetArguments(IShellLinkA * iface, LPCSTR psz
TRACE("(%p)->(args=%s)\n",This, pszArgs);
HeapFree(GetProcessHeap(), 0, This->sArgs);
This->sArgs = HEAP_strdupAtoW( GetProcessHeap(), 0, pszArgs);
if( !This->sArgs )
return E_OUTOFMEMORY;
if (pszArgs)
{
This->sArgs = HEAP_strdupAtoW( GetProcessHeap(), 0, pszArgs);
if( !This->sArgs )
return E_OUTOFMEMORY;
}
else This->sArgs = NULL;
This->bDirty = TRUE;
@ -1877,11 +1881,16 @@ static HRESULT WINAPI IShellLinkW_fnSetArguments(IShellLinkW * iface, LPCWSTR ps
TRACE("(%p)->(args=%s)\n",This, debugstr_w(pszArgs));
HeapFree(GetProcessHeap(), 0, This->sArgs);
This->sArgs = HeapAlloc( GetProcessHeap(), 0,
(lstrlenW( pszArgs )+1)*sizeof (WCHAR) );
if ( !This->sArgs )
return E_OUTOFMEMORY;
lstrcpyW( This->sArgs, pszArgs );
if (pszArgs)
{
This->sArgs = HeapAlloc( GetProcessHeap(), 0,
(lstrlenW( pszArgs )+1)*sizeof (WCHAR) );
if ( !This->sArgs )
return E_OUTOFMEMORY;
lstrcpyW( This->sArgs, pszArgs );
}
else This->sArgs = NULL;
This->bDirty = TRUE;
return S_OK;

View File

@ -275,6 +275,20 @@ static void test_get_set(void)
ok(SUCCEEDED(r), "GetArguments failed (0x%08x)\n", r);
ok(lstrcmp(buffer,str)==0, "GetArguments returned '%s'\n", buffer);
strcpy(buffer,"garbage");
r = IShellLinkA_SetArguments(sl, NULL);
ok(SUCCEEDED(r), "SetArguments failed (0x%08x)\n", r);
r = IShellLinkA_GetArguments(sl, buffer, sizeof(buffer));
ok(SUCCEEDED(r), "GetArguments failed (0x%08x)\n", r);
ok(!buffer[0] || lstrcmp(buffer,str)==0, "GetArguments returned '%s'\n", buffer);
strcpy(buffer,"garbage");
r = IShellLinkA_SetArguments(sl, "");
ok(SUCCEEDED(r), "SetArguments failed (0x%08x)\n", r);
r = IShellLinkA_GetArguments(sl, buffer, sizeof(buffer));
ok(SUCCEEDED(r), "GetArguments failed (0x%08x)\n", r);
ok(!buffer[0], "GetArguments returned '%s'\n", buffer);
/* Test Getting / Setting showcmd */
i=0xdeadbeef;
r = IShellLinkA_GetShowCmd(sl, &i);