diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index e25f2eaeb54..63926e22243 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -1468,9 +1468,11 @@ static HRESULT WINAPI ITextRange_fnGetChar(ITextRange *me, LONG *pch) ITextRangeImpl *This = impl_from_ITextRange(me); ME_Cursor cursor; + TRACE("(%p)->(%p)\n", This, pch); + if (!This->reOle) return CO_E_RELEASED; - TRACE("%p\n", pch); + if (!pch) return E_INVALIDARG; @@ -3934,9 +3936,11 @@ static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch) ITextSelectionImpl *This = impl_from_ITextSelection(me); ME_Cursor *start = NULL, *end = NULL; + TRACE("(%p)->(%p)\n", This, pch); + if (!This->reOle) return CO_E_RELEASED; - TRACE("%p\n", pch); + if (!pch) return E_INVALIDARG; diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 33a433a825c..3e41ede1bca 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -683,7 +683,7 @@ static void test_ITextRange_GetChar(void) ITextDocument *txtDoc = NULL; ITextRange *txtRge = NULL; HRESULT hres; - LONG pch = 0xdeadbeef; + LONG pch; int first, lim; static const CHAR test_text1[] = "TestSomeText"; @@ -742,8 +742,16 @@ static void test_ITextRange_GetChar(void) ok(hres == S_OK, "got 0x%08x\n", hres); hres = ITextRange_GetChar(txtRge, NULL); ok(hres == E_INVALIDARG, "ITextRange_GetChar\n"); - ITextRange_Release(txtRge); + release_interfaces(&w, &reOle, &txtDoc, NULL); + + hres = ITextRange_GetChar(txtRge, NULL); + ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + + hres = ITextRange_GetChar(txtRge, &pch); + ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + + ITextRange_Release(txtRge); } static void test_ITextSelection_GetChar(void) @@ -753,7 +761,7 @@ static void test_ITextSelection_GetChar(void) ITextDocument *txtDoc = NULL; ITextSelection *txtSel = NULL; HRESULT hres; - LONG pch = 0xdeadbeef; + LONG pch; int first, lim; static const CHAR test_text1[] = "TestSomeText"; @@ -791,7 +799,15 @@ static void test_ITextSelection_GetChar(void) hres = ITextSelection_GetChar(txtSel, NULL); ok(hres == E_INVALIDARG, "ITextSelection_GetChar\n"); - release_interfaces(&w, &reOle, &txtDoc, &txtSel); + release_interfaces(&w, &reOle, &txtDoc, NULL); + + hres = ITextSelection_GetChar(txtSel, NULL); + ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + + hres = ITextSelection_GetChar(txtSel, &pch); + ok(hres == CO_E_RELEASED, "got 0x%08x\n", hres); + + ITextSelection_Release(txtSel); } static void test_ITextRange_GetStart_GetEnd(void)