[PATCH 2/9] taskschd: IRegistrationInfo::put_Author() should accept NULL input.

Dmitry Timoshkov dmitry at baikal.ru
Mon Apr 2 00:26:53 CDT 2018


Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 dlls/taskschd/task.c            |  9 ++++-----
 dlls/taskschd/tests/scheduler.c | 10 ++++++++++
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/dlls/taskschd/task.c b/dlls/taskschd/task.c
index 933d833016..7ae478f58c 100644
--- a/dlls/taskschd/task.c
+++ b/dlls/taskschd/task.c
@@ -608,15 +608,14 @@ static HRESULT WINAPI RegistrationInfo_get_Author(IRegistrationInfo *iface, BSTR
 static HRESULT WINAPI RegistrationInfo_put_Author(IRegistrationInfo *iface, BSTR author)
 {
     registration_info *reginfo = impl_from_IRegistrationInfo(iface);
+    WCHAR *str = NULL;
 
     TRACE("%p,%s\n", iface, debugstr_w(author));
 
-    if (!author) return E_INVALIDARG;
-
+    if (author && !(str = heap_strdupW(author))) return E_OUTOFMEMORY;
     heap_free(reginfo->author);
-    reginfo->author = heap_strdupW(author);
-    /* FIXME: update XML on the server side */
-    return reginfo->author ? S_OK : E_OUTOFMEMORY;
+    reginfo->author = str;
+    return S_OK;
 }
 
 static HRESULT WINAPI RegistrationInfo_get_Version(IRegistrationInfo *iface, BSTR *version)
diff --git a/dlls/taskschd/tests/scheduler.c b/dlls/taskschd/tests/scheduler.c
index 82f3315099..d006dff703 100644
--- a/dlls/taskschd/tests/scheduler.c
+++ b/dlls/taskschd/tests/scheduler.c
@@ -1424,6 +1424,7 @@ static void test_TaskDefinition(void)
         "<Task xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n"
         "  <RegistrationInfo>\n"
         "    <Description>\"Task1\"</Description>\n"
+        "    <Author>author</Author>\n"
         "  </RegistrationInfo>\n"
         "  <Settings>\n"
         "    <Enabled>false</Enabled>\n"
@@ -1503,6 +1504,7 @@ static void test_TaskDefinition(void)
         "    </Exec>\n"
         "  </Actions>\n"
         "</Task>\n";
+    static const WCHAR authorW[] = { 'a','u','t','h','o','r',0 };
     static WCHAR Task1[] = { '"','T','a','s','k','1','"',0 };
     static struct settings def_settings = { { 0 }, { 'P','T','7','2','H',0 }, { 0 },
         0, 7, TASK_INSTANCES_IGNORE_NEW, TASK_COMPATIBILITY_V2, VARIANT_TRUE, VARIANT_TRUE,
@@ -1609,9 +1611,17 @@ todo_wine
     ok(hr == S_OK, "get_Description error %#x\n", hr);
     ok(!bstr, "expected NULL, got %s\n", wine_dbgstr_w(bstr));
 
+    hr = IRegistrationInfo_get_Author(reginfo, &bstr);
+    ok(hr == S_OK, "get_Author error %#x\n", hr);
+    ok(!lstrcmpW(bstr, authorW), "expected %s, got %s\n", wine_dbgstr_w(authorW), wine_dbgstr_w(bstr));
+    SysFreeString(bstr);
+    hr = IRegistrationInfo_put_Author(reginfo, NULL);
+    ok(hr == S_OK, "put_Author error %#x\n", hr);
+    bstr = (BSTR)0xdeadbeef;
     hr = IRegistrationInfo_get_Author(reginfo, &bstr);
     ok(hr == S_OK, "get_Author error %#x\n", hr);
     ok(!bstr, "expected NULL, got %s\n", wine_dbgstr_w(bstr));
+
     hr = IRegistrationInfo_get_Version(reginfo, &bstr);
     ok(hr == S_OK, "get_Version error %#x\n", hr);
     ok(!bstr, "expected NULL, got %s\n", wine_dbgstr_w(bstr));
-- 
2.16.3




More information about the wine-devel mailing list