Alistair Leslie-Hughes : inetcomm: Improve IMimeBody GetHandle return value.

Alexandre Julliard julliard at winehq.org
Mon Jul 18 09:22:33 CDT 2016


Module: wine
Branch: master
Commit: b8b7db8be81640c9045200ef042e7ace134dd42a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b8b7db8be81640c9045200ef042e7ace134dd42a

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Tue Jul 12 08:02:34 2016 +0000

inetcomm: Improve IMimeBody GetHandle return value.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/inetcomm/mimeole.c       |  5 +++++
 dlls/inetcomm/tests/mimeole.c | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c
index f4537f3..23bd930 100644
--- a/dlls/inetcomm/mimeole.c
+++ b/dlls/inetcomm/mimeole.c
@@ -1314,6 +1314,9 @@ static HRESULT WINAPI MimeBody_GetHandle(
     MimeBody *This = impl_from_IMimeBody(iface);
     TRACE("(%p)->(%p)\n", iface, phBody);
 
+    if(!phBody)
+        return E_INVALIDARG;
+
     *phBody = This->handle;
     return This->handle ? S_OK : MIME_E_NO_DATA;
 }
@@ -1819,6 +1822,8 @@ static body_t *new_body_entry(MimeBody *mime_body, DWORD index, body_t *parent)
         body->index = index;
         list_init(&body->children);
         body->parent = parent;
+
+        mime_body->handle = UlongToHandle(body->index);
     }
     return body;
 }
diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c
index 84b2c8d..58d0520 100644
--- a/dlls/inetcomm/tests/mimeole.c
+++ b/dlls/inetcomm/tests/mimeole.c
@@ -220,6 +220,7 @@ static void test_CreateMessage(void)
     ULONG count;
     FINDBODY find_struct;
     HCHARSET hcs;
+    HBODY handle = NULL;
 
     char text[] = "text";
     HBODY *body_list;
@@ -258,6 +259,13 @@ static void test_CreateMessage(void)
     hr = IMimeMessage_GetBody(msg, IBL_ROOT, NULL, &hbody);
     ok(hr == S_OK, "ret %08x\n", hr);
 
+    hr = IMimeBody_GetHandle(body, NULL);
+    ok(hr == E_INVALIDARG, "ret %08x\n", hr);
+
+    hr = IMimeBody_GetHandle(body, &handle);
+    ok(hr == S_OK, "ret %08x\n", hr);
+    ok(handle != NULL, "handle %p\n", handle);
+
     PropVariantInit(&prop);
     hr = IMimeMessage_GetBodyProp(msg, hbody, att_pritype, 0, &prop);
     ok(hr == S_OK, "ret %08x\n", hr);
@@ -269,6 +277,11 @@ static void test_CreateMessage(void)
     ok(hr == S_OK, "ret %08x\n", hr);
     hr = IMimeMessage_BindToObject(msg, hbody, &IID_IMimeBody, (void**)&body);
     ok(hr == S_OK, "ret %08x\n", hr);
+
+    hr = IMimeBody_GetHandle(body, &handle);
+    ok(hr == S_OK, "ret %08x\n", hr);
+    ok(handle == hbody, "handle %p\n", handle);
+
     hr = IMimeBody_GetOffsets(body, &offsets);
     ok(hr == S_OK, "ret %08x\n", hr);
     ok(offsets.cbBoundaryStart == 405, "got %d\n", offsets.cbBoundaryStart);
@@ -289,6 +302,11 @@ static void test_CreateMessage(void)
     ok(hr == S_OK, "ret %08x\n", hr);
     hr = IMimeMessage_BindToObject(msg, hbody, &IID_IMimeBody, (void**)&body);
     ok(hr == S_OK, "ret %08x\n", hr);
+
+    hr = IMimeBody_GetHandle(body, &handle);
+    ok(hr == S_OK, "ret %08x\n", hr);
+    ok(handle == hbody, "handle %p\n", handle);
+
     hr = IMimeBody_GetOffsets(body, &offsets);
     ok(hr == S_OK, "ret %08x\n", hr);
     ok(offsets.cbBoundaryStart == 525, "got %d\n", offsets.cbBoundaryStart);




More information about the wine-cvs mailing list