cmd: Fix possible NULL pointer access in heap_strdupW

Frédéric Delanoy frederic.delanoy at gmail.com
Mon Nov 19 05:38:56 CST 2012


On Sat, Nov 17, 2012 at 10:52 PM, André Hentschel <nerv at dawncrow.de> wrote:
> we already do that (ieframe,vbscript,wininet,.. are good examples), but not consistent all over the place
> ---
>  programs/cmd/wcmd.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h
> index 3cc4c0b..303d260 100644
> --- a/programs/cmd/wcmd.h
> +++ b/programs/cmd/wcmd.h
> @@ -142,7 +142,8 @@ static inline WCHAR *heap_strdupW(const WCHAR *str)
>
>          size = (strlenW(str)+1)*sizeof(WCHAR);
>          ret = heap_alloc(size);
> -        memcpy(ret, str, size);
> +        if(ret)
> +            memcpy(ret, str, size);
>      }
>
>      return ret;
> --
> 1.8.0

heap_alloc is cmd was made infallible, so this isn't necessary
(c6d24089dbc284f0fef5e1ce37b75ac04c6ebd94)

Frédéric



More information about the wine-devel mailing list