gameux/gamestatistics.c: Make sure each VARIANT is cleared after use (valgrind)

Alexandre Julliard julliard at winehq.org
Wed Feb 16 07:20:20 CST 2011


Joris Huizer <joris_huizer at yahoo.com> writes:

> @@ -511,24 +511,27 @@ static HRESULT GAMEUX_loadStatisticsFromFile(struct GAMEUX_STATS *data)
>  
>                  if(SUCCEEDED(hr))
>                  {
> -                    hr = IXMLDOMElement_getAttribute(categoryElement, bstrIndex, &vValue);
> -                    if( hr == S_OK && V_VT(&vValue) != VT_BSTR)
> +                    VARIANT categoryIndex, categoryName;
> +                    hr = IXMLDOMElement_getAttribute(categoryElement, bstrIndex, &categoryIndex);
> +                    if( hr == S_OK && V_VT(&categoryIndex) != VT_BSTR)
>                          hr = E_FAIL;
>  
>                      if(SUCCEEDED(hr))
>                      {
> -                        i = StrToIntW(V_BSTR(&vValue));
> -                        hr = IXMLDOMElement_getAttribute(categoryElement, bstrName, &vValue);
> -                        if( hr == S_OK && V_VT(&vValue) != VT_BSTR)
> +                        i = StrToIntW(V_BSTR(&categoryIndex));
> +                        hr = IXMLDOMElement_getAttribute(categoryElement, bstrName, &categoryName);
> +                        if( hr == S_OK && V_VT(&categoryName) != VT_BSTR)
>                              hr = E_FAIL;
>                      }
> +                    VariantClear(&categoryIndex);

You should only clear it when it has been successfully set.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list