From 10a832cc042075b828322ea94a58af14720954f0 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 6 Dec 2012 14:24:14 +0100 Subject: [PATCH] mshtml: Properly handle NULL value in set_nsstyle_attr. --- dlls/mshtml/htmlstyle.c | 12 +++++++----- dlls/mshtml/tests/style.c | 13 +++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index 6427bee1c7a..95d7a889c7c 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -351,16 +351,18 @@ static LPWSTR fix_url_value(LPCWSTR val) return ret; } -HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, LPCWSTR value, DWORD flags) +HRESULT set_nsstyle_attr(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid, const WCHAR *value, DWORD flags) { nsAString str_name, str_value, str_empty; LPWSTR val = NULL; nsresult nsres; - if(flags & ATTR_FIX_PX) - val = fix_px_value(value); - if(flags & ATTR_FIX_URL) - val = fix_url_value(value); + if(value) { + if(flags & ATTR_FIX_PX) + val = fix_px_value(value); + if(flags & ATTR_FIX_URL) + val = fix_url_value(value); + } nsAString_InitDepend(&str_name, style_tbl[sid].name); nsAString_InitDepend(&str_value, val ? val : value); diff --git a/dlls/mshtml/tests/style.c b/dlls/mshtml/tests/style.c index fd0f78e17d7..08b3a3c6774 100644 --- a/dlls/mshtml/tests/style.c +++ b/dlls/mshtml/tests/style.c @@ -1052,6 +1052,19 @@ static void test_body_style(IHTMLStyle *style) ok(!strcmp_wa(V_BSTR(&v), "70px"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = NULL; + hres = IHTMLStyle_put_height(style, v); + ok(hres == S_OK, "put_height failed: %08x\n", hres); + VariantClear(&v); + + V_VT(&v) = VT_EMPTY; + hres = IHTMLStyle_get_height(style, &v); + ok(hres == S_OK, "get_height failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v)); + ok(!V_BSTR(&v), "V_BSTR(v) = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + V_VT(&v) = VT_I4; V_I4(&v) = 64; hres = IHTMLStyle_put_height(style, v);