Re: [ros-diffs] [reactos] 01/01: [POWERCFG] Fix an exception that occurs when the control panel is closed.

Thomas Faber <[email protected]> Sat, 4 May 2019 07:43:16 +0200
Newsgroups gmane.os.reactos.kernel
Message-ID <[email protected]>
This fix seems odd. I thought HeapFree(NULL) was well-defined and did 
nothing (despite what MSDN says). Pretty sure Wine uses it everywhere.
Am I missing something?


On 2019-04-27 19:02, Eric Kohl wrote:
> https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ce218f70ec8a758ec6d4039690bae29c23289b9d
> 
> commit ce218f70ec8a758ec6d4039690bae29c23289b9d
> Author:     Eric Kohl <[email protected]>
> AuthorDate: Sat Apr 27 19:00:33 2019 +0200
> Commit:     Eric Kohl <[email protected]>
> CommitDate: Sat Apr 27 19:01:35 2019 +0200
> 
>      [POWERCFG] Fix an exception that occurs when the control panel is closed.
> ---
>   dll/cpl/powercfg/powershemes.c | 16 ++++++++++++----
>   1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/dll/cpl/powercfg/powershemes.c b/dll/cpl/powercfg/powershemes.c
> index 4fff28a279..7d1441a043 100644
> --- a/dll/cpl/powercfg/powershemes.c
> +++ b/dll/cpl/powercfg/powershemes.c
> @@ -78,8 +78,12 @@ AddPowerScheme(
>                                           dwDescription + sizeof(TCHAR));
>       if (pScheme->pszName == NULL || pScheme->pszDescription == NULL)
>       {
> -        HeapFree(GetProcessHeap(), 0, pScheme->pszName);
> -        HeapFree(GetProcessHeap(), 0, pScheme->pszDescription);
> +        if (pScheme->pszName)
> +            HeapFree(GetProcessHeap(), 0, pScheme->pszName);
> +
> +        if (pScheme->pszDescription)
> +            HeapFree(GetProcessHeap(), 0, pScheme->pszDescription);
> +
>           HeapFree(GetProcessHeap(), 0, pScheme);
>           return NULL;
>       }
> @@ -103,8 +107,12 @@ DeletePowerScheme(
>   {
>       RemoveEntryList(&pScheme->ListEntry);
>   
> -    HeapFree(GetProcessHeap(), 0, pScheme->pszName);
> -    HeapFree(GetProcessHeap(), 0, pScheme->pszDescription);
> +    if (pScheme->pszName)
> +        HeapFree(GetProcessHeap(), 0, pScheme->pszName);
> +
> +    if (pScheme->pszDescription)
> +        HeapFree(GetProcessHeap(), 0, pScheme->pszDescription);
> +
>       HeapFree(GetProcessHeap(), 0, pScheme);
>   }
>   
> 


_______________________________________________
Ros-dev mailing list
[email protected]
http://reactos.org/mailman/listinfo/ros-dev