msi: Dont crash on installation of services without component KeyPath
Hans Leidekker
hans at codeweavers.com
Wed Feb 19 02:51:14 CST 2014
On Wed, 2014-02-19 at 14:49 +0900, Aric Stewart wrote:
> diff --git a/dlls/msi/action.c b/dlls/msi/action.c
> index 07322fe..a004225 100644
> --- a/dlls/msi/action.c
> +++ b/dlls/msi/action.c
> @@ -5794,27 +5794,30 @@ static UINT ITERATE_InstallService(MSIRECORD *rec, LPVOID param)
> goto done;
> }
> key = MSI_RecordGetString(row, 6);
> - file = msi_get_loaded_file(package, key);
> - msiobj_release(&row->hdr);
> - if (!file)
> - {
> - ERR("Failed to load the service file\n");
> - goto done;
> - }
> -
> - if (!args || !args[0]) image_path = file->TargetPath;
> - else
> + if (key)
> {
> - int len = strlenW(file->TargetPath) + strlenW(args) + 2;
> - if (!(image_path = msi_alloc(len * sizeof(WCHAR))))
> + file = msi_get_loaded_file(package, key);
> + msiobj_release(&row->hdr);
> + if (!file)
> {
> - ret = ERROR_OUTOFMEMORY;
> + ERR("Failed to load the service file\n");
> goto done;
> }
>
> - strcpyW(image_path, file->TargetPath);
> - strcatW(image_path, szSpace);
> - strcatW(image_path, args);
> + if (!args || !args[0]) image_path = file->TargetPath;
> + else
> + {
> + int len = strlenW(file->TargetPath) + strlenW(args) + 2;
> + if (!(image_path = msi_alloc(len * sizeof(WCHAR))))
> + {
> + ret = ERROR_OUTOFMEMORY;
> + goto done;
> + }
> +
> + strcpyW(image_path, file->TargetPath);
> + strcatW(image_path, szSpace);
> + strcatW(image_path, args);
> + }
> }
> service = CreateServiceW(hscm, name, disp, GENERIC_ALL, serv_type,
> start_type, err_control, image_path, load_order,
> @@ -5831,7 +5834,7 @@ static UINT ITERATE_InstallService(MSIRECORD *rec, LPVOID param)
> WARN("failed to set service description %u\n", GetLastError());
> }
>
> - if (image_path != file->TargetPath) msi_free(image_path);
> + if (image_path && image_path != file->TargetPath) msi_free(image_path);
> done:
> CloseServiceHandle(service);
> CloseServiceHandle(hscm);
Should we still create the service if the installer doesn't specify the image path?
More information about the wine-devel
mailing list