X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwinjump.c;h=eca5041a8dfa949da3e91321d494ffcf354c95c6;hb=5471539a6738484b48fb938c88dce547a3e4b299;hp=6552e074051ef2387548493370a5ebad6438a8a9;hpb=1a03fa9292f2258384d037994d8e8e119ac11458;p=PuTTY.git diff --git a/windows/winjump.c b/windows/winjump.c index 6552e074..eca5041a 100644 --- a/windows/winjump.c +++ b/windows/winjump.c @@ -40,6 +40,11 @@ typedef struct _tagpropertykey { #define _REFPROPVARIANT_DEFINED typedef PROPVARIANT *REFPROPVARIANT; #endif +/* MinGW doesn't define this yet: */ +#ifndef _PROPVARIANTINIT_DEFINED_ +#define _PROPVARIANTINIT_DEFINED_ +#define PropVariantInit(pvar) memset((pvar),0,sizeof(PROPVARIANT)) +#endif #define IID_IShellLink IID_IShellLinkA @@ -348,7 +353,12 @@ static const PROPERTYKEY PKEY_Title = { 0x00000002 }; -#define COMPTR(type, obj) &IID_##type, ((sizeof((obj)-(type **)(obj))), (obj)) +/* Type-checking macro to provide arguments for CoCreateInstance() + * etc, ensuring that 'obj' really is a 'type **'. */ +#define typecheck(checkexpr, result) \ + (sizeof(checkexpr) ? (result) : (result)) +#define COMPTR(type, obj) &IID_##type, \ + typecheck((obj)-(type **)(obj), (void **)(void *)(obj)) static char putty_path[2048]; @@ -400,22 +410,30 @@ static IShellLink *make_shell_link(const char *appname, /* Check if this is a valid session, otherwise don't add. */ if (sessionname) { psettings_tmp = open_settings_r(sessionname); - if (!psettings_tmp) + if (!psettings_tmp) { + sfree(app_path); return NULL; + } close_settings_r(psettings_tmp); } /* Create the new item. */ if (!SUCCEEDED(CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, - COMPTR(IShellLink, &ret)))) + COMPTR(IShellLink, &ret)))) { + sfree(app_path); return NULL; + } /* Set path, parameters, icon and description. */ ret->lpVtbl->SetPath(ret, app_path); if (sessionname) { - param_string = dupcat("@", sessionname, NULL); + /* The leading space is reported to work around a Windows 10 + * behaviour change in which an argument string starting with + * '@' causes the SetArguments method to silently do the wrong + * thing. */ + param_string = dupcat(" @", sessionname, NULL); } else { param_string = dupstr(""); } @@ -653,11 +671,9 @@ static void update_jumplist_from_registry(void) } /* Clears the entire jumplist. */ -static void clear_jumplist(void) +void clear_jumplist(void) { ICustomDestinationList *pCDL; - UINT num_items; - IObjectArray *pRemoved; if (CoCreateInstance(&CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, COMPTR(ICustomDestinationList, &pCDL)) == S_OK) {