Dmitry Timoshkov : taskschd: IRegistrationInfo::put_Date() should accept NULL input.

Alexandre Julliard julliard at winehq.org
Mon Apr 2 16:32:52 CDT 2018


Module: wine
Branch: master
Commit: 57c936b05c3c9ad02afd18236b8d657a678a2a70
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=57c936b05c3c9ad02afd18236b8d657a678a2a70

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Mon Apr  2 13:26:58 2018 +0800

taskschd: IRegistrationInfo::put_Date() should accept NULL input.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/taskschd/task.c            | 15 ++++++++++-----
 dlls/taskschd/tests/scheduler.c | 10 ++++++++++
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/dlls/taskschd/task.c b/dlls/taskschd/task.c
index 02e7cae..c226446 100644
--- a/dlls/taskschd/task.c
+++ b/dlls/taskschd/task.c
@@ -662,15 +662,14 @@ static HRESULT WINAPI RegistrationInfo_get_Date(IRegistrationInfo *iface, BSTR *
 static HRESULT WINAPI RegistrationInfo_put_Date(IRegistrationInfo *iface, BSTR date)
 {
     registration_info *reginfo = impl_from_IRegistrationInfo(iface);
+    WCHAR *str = NULL;
 
     TRACE("%p,%s\n", iface, debugstr_w(date));
 
-    if (!date) return E_INVALIDARG;
-
+    if (date && !(str = heap_strdupW(date))) return E_OUTOFMEMORY;
     heap_free(reginfo->date);
-    reginfo->date = heap_strdupW(date);
-    /* FIXME: update XML on the server side */
-    return reginfo->date ? S_OK : E_OUTOFMEMORY;
+    reginfo->date = str;
+    return S_OK;
 }
 
 static HRESULT WINAPI RegistrationInfo_get_Documentation(IRegistrationInfo *iface, BSTR *doc)
@@ -3326,6 +3325,12 @@ static HRESULT read_registration_info(IXmlReader *reader, IRegistrationInfo *inf
                 if (hr == S_OK)
                     IRegistrationInfo_put_Version(info, value);
             }
+            else if (!lstrcmpW(name, Date))
+            {
+                hr = read_text_value(reader, &value);
+                if (hr == S_OK)
+                    IRegistrationInfo_put_Date(info, value);
+            }
             else
                 FIXME("unhandled RegistrationInfo element %s\n", debugstr_w(name));
 
diff --git a/dlls/taskschd/tests/scheduler.c b/dlls/taskschd/tests/scheduler.c
index c46d849..2e6a8c4 100644
--- a/dlls/taskschd/tests/scheduler.c
+++ b/dlls/taskschd/tests/scheduler.c
@@ -1426,6 +1426,7 @@ static void test_TaskDefinition(void)
         "    <Description>\"Task1\"</Description>\n"
         "    <Author>author</Author>\n"
         "    <Version>1.0</Version>\n"
+        "    <Date>2018-04-02T11:22:33</Date>\n"
         "  </RegistrationInfo>\n"
         "  <Settings>\n"
         "    <Enabled>false</Enabled>\n"
@@ -1507,6 +1508,7 @@ static void test_TaskDefinition(void)
         "</Task>\n";
     static const WCHAR authorW[] = { 'a','u','t','h','o','r',0 };
     static const WCHAR versionW[] = { '1','.','0',0 };
+    static const WCHAR dateW[] = { '2','0','1','8','-','0','4','-','0','2','T','1','1',':','2','2',':','3','3',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,
@@ -1637,7 +1639,15 @@ todo_wine
 
     hr = IRegistrationInfo_get_Date(reginfo, &bstr);
     ok(hr == S_OK, "get_Date error %#x\n", hr);
+    ok(!lstrcmpW(bstr, dateW), "expected %s, got %s\n", wine_dbgstr_w(dateW), wine_dbgstr_w(bstr));
+    SysFreeString(bstr);
+    hr = IRegistrationInfo_put_Date(reginfo, NULL);
+    ok(hr == S_OK, "put_Date error %#x\n", hr);
+    bstr = (BSTR)0xdeadbeef;
+    hr = IRegistrationInfo_get_Date(reginfo, &bstr);
+    ok(hr == S_OK, "get_Date error %#x\n", hr);
     ok(!bstr, "expected NULL, got %s\n", wine_dbgstr_w(bstr));
+
     hr = IRegistrationInfo_get_Documentation(reginfo, &bstr);
     ok(hr == S_OK, "get_Documentation error %#x\n", hr);
     ok(!bstr, "expected NULL, got %s\n", wine_dbgstr_w(bstr));




More information about the wine-cvs mailing list