From ed880969b37c873ce6d46bcc1e03177228e4061e Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Tue, 12 Jul 2016 08:02:46 +0000 Subject: [PATCH] inetcomm: GetBody returns MIME_E_NOT_FOUND when no parent found. Signed-off-by: Alistair Leslie-Hughes Signed-off-by: Alexandre Julliard --- dlls/inetcomm/mimeole.c | 10 +++++++++- dlls/inetcomm/tests/mimeole.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c index 23bd9309c0d..6046c747ded 100644 --- a/dlls/inetcomm/mimeole.c +++ b/dlls/inetcomm/mimeole.c @@ -2175,7 +2175,10 @@ static HRESULT get_body(MimeMessage *msg, BODYLOCATION location, HBODY pivot, bo switch(location) { case IBL_PARENT: - *out = body->parent; + if(body->parent) + *out = body->parent; + else + hr = MIME_E_NOT_FOUND; break; case IBL_FIRST: @@ -2239,6 +2242,11 @@ static HRESULT WINAPI MimeMessage_GetBody(IMimeMessage *iface, BODYLOCATION loca TRACE("(%p)->(%d, %p, %p)\n", iface, location, hPivot, phBody); + if(!phBody) + return E_INVALIDARG; + + *phBody = NULL; + hr = get_body(This, location, hPivot, &body); if(hr == S_OK) *phBody = UlongToHandle(body->index); diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c index 58d0520e740..011c19f40d6 100644 --- a/dlls/inetcomm/tests/mimeole.c +++ b/dlls/inetcomm/tests/mimeole.c @@ -214,7 +214,7 @@ static void test_CreateMessage(void) IStream *stream; LARGE_INTEGER pos; LONG ref; - HBODY hbody; + HBODY hbody, hbody2; IMimeBody *body; BODYOFFSETS offsets; ULONG count; @@ -266,6 +266,14 @@ static void test_CreateMessage(void) ok(hr == S_OK, "ret %08x\n", hr); ok(handle != NULL, "handle %p\n", handle); + hr = IMimeMessage_GetBody(msg, IBL_PARENT, hbody, NULL); + ok(hr == E_INVALIDARG, "ret %08x\n", hr); + + hbody2 = (HBODY)0xdeadbeef; + hr = IMimeMessage_GetBody(msg, IBL_PARENT, hbody, &hbody2); + ok(hr == MIME_E_NOT_FOUND, "ret %08x\n", hr); + ok(hbody2 == NULL, "hbody2 %p\n", hbody2); + PropVariantInit(&prop); hr = IMimeMessage_GetBodyProp(msg, hbody, att_pritype, 0, &prop); ok(hr == S_OK, "ret %08x\n", hr);