Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/richole.c | 6 +++++- dlls/riched20/tests/richole.c | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index dc1a3b8405..93fe203cf2 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -1393,7 +1393,11 @@ IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob, } else { - if (iob > IRichEditOle_GetObjectCount(me)) + int object_count = IRichEditOle_GetObjectCount(me); + + if (iob == -1) + iob = object_count - 1; + if (iob < 0 || iob >= object_count) return E_INVALIDARG; LIST_FOR_EACH_ENTRY(reobj, &This->editor->reobj_list, struct re_object, entry) { diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index d3ffdce4a7..5b46dafcdc 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3276,9 +3276,18 @@ static void test_InsertObject(void) ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); CHECK_REOBJECT_STRUCT(received_reo3, NULL, NULL, reo2.polesite, 2);
+ received_reo3.cbStruct = sizeof(received_reo3); + hr = IRichEditOle_GetObject(reole, -1, &received_reo3, REO_GETOBJ_ALL_INTERFACES); + ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); + CHECK_REOBJECT_STRUCT(received_reo3, NULL, NULL, reo2.polesite, 2); + hr = IRichEditOle_GetObject(reole, 2, NULL, REO_GETOBJ_ALL_INTERFACES); ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
+ received_reo4.cbStruct = sizeof(received_reo4); + hr = IRichEditOle_GetObject(reole, -2, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr); + received_reo4.cbStruct = 0; hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_ALL_INTERFACES); ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);