msi: Fix some leaks (coverity)

Hans Leidekker hans at codeweavers.com
Thu Nov 8 01:58:45 CST 2012


On Thu, 2012-11-08 at 01:32 +0100, Frédéric Delanoy wrote:
> diff --git a/dlls/msi/action.c b/dlls/msi/action.c
> index f9ab550..8a6c952 100644
> --- a/dlls/msi/action.c
> +++ b/dlls/msi/action.c
> @@ -5809,7 +5809,16 @@ static UINT ITERATE_InstallService(MSIRECORD *rec, LPVOID param)
>      {
>          int len = strlenW(file->TargetPath) + strlenW(args) + 2;
>          if (!(image_path = msi_alloc(len * sizeof(WCHAR))))
> +        {
> +            msi_free(name);
> +            msi_free(disp);
> +            msi_free(load_order);
> +            msi_free(serv_name);
> +            msi_free(pass);
> +            msi_free(depends);
> +            msi_free(args);
>              return ERROR_OUTOFMEMORY;
> +        }

This function already has a 'done' label where memory is freed. Why not make the
return value a variable and jump to the label instead of repeating these statements?

>          strcpyW(image_path, file->TargetPath);
>          strcatW(image_path, szSpace);
> @@ -6070,6 +6079,7 @@ static BOOL stop_service_dependents(SC_HANDLE scm, SC_HANDLE service)
>              goto error;
>      }
>  
> +    msi_free(dependencies);
>      return TRUE;

Same here.
>  
>  error:
> diff --git a/dlls/msi/files.c b/dlls/msi/files.c
> index 11913ef..98d7513 100644
> --- a/dlls/msi/files.c
> +++ b/dlls/msi/files.c
> @@ -336,6 +336,7 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package)
>          if (rc != ERROR_SUCCESS)
>          {
>              ERR("Unable to load media info for %s (%u)\n", debugstr_w(file->File), rc);
> +            msi_free(mi);
>              return ERROR_FUNCTION_FAILED;
>          }
>          if (!file->Component->Enabled) continue;
> @@ -513,6 +514,7 @@ UINT ACTION_PatchFiles( MSIPACKAGE *package )
>          if (rc != ERROR_SUCCESS)
>          {
>              ERR("Unable to load media info for %s (%u)\n", debugstr_w(file->File), rc);
> +            msi_free(mi);
>              return ERROR_FUNCTION_FAILED;
>          }
>          comp->Action = msi_get_component_action( package, comp );

And here.





More information about the wine-devel mailing list