Hans Leidekker : msado15: Prevent multiple Open/Close of a _Recordset.

Alexandre Julliard julliard at winehq.org
Fri Dec 13 15:27:22 CST 2019


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

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Fri Dec 13 15:52:31 2019 +0100

msado15: Prevent multiple Open/Close of a _Recordset.

Based on a patch by Alistair Leslie-Hughes.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msado15/recordset.c     | 5 +++++
 dlls/msado15/tests/msado15.c | 8 +++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/dlls/msado15/recordset.c b/dlls/msado15/recordset.c
index 56cdee6652..1d28d6b957 100644
--- a/dlls/msado15/recordset.c
+++ b/dlls/msado15/recordset.c
@@ -1035,6 +1035,8 @@ static HRESULT WINAPI recordset_Close( _Recordset *iface )
 
     TRACE( "%p\n", recordset );
 
+    if (recordset->state == adStateClosed) return MAKE_ADO_HRESULT( adErrObjectClosed );
+
     close_recordset( recordset );
     recordset->state = adStateClosed;
     return S_OK;
@@ -1106,6 +1108,9 @@ static HRESULT WINAPI recordset_Open( _Recordset *iface, VARIANT source, VARIANT
     FIXME( "%p, %s, %s, %d, %d, %d\n", recordset, debugstr_variant(&source), debugstr_variant(&active_connection),
            cursor_type, lock_type, options );
 
+    if (!recordset->fields) return MAKE_ADO_HRESULT( adErrInvalidConnection );
+    if (recordset->state == adStateOpen) return MAKE_ADO_HRESULT( adErrObjectOpen );
+
     recordset->state = adStateOpen;
     return S_OK;
 }
diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c
index ff0004c72b..afdf0dfb6a 100644
--- a/dlls/msado15/tests/msado15.c
+++ b/dlls/msado15/tests/msado15.c
@@ -114,6 +114,9 @@ static void test_Recordset(void)
     ok( hr == S_OK, "got %08x\n", hr );
     ok( !count, "got %d\n", count );
 
+    hr = _Recordset_Close( recordset );
+    ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08x\n", hr );
+
     refs = _Recordset_Release( recordset );
     ok( !refs, "got %d\n", refs );
 
@@ -136,7 +139,7 @@ static void test_Recordset(void)
     V_VT( &missing ) = VT_ERROR;
     V_ERROR( &missing ) = DISP_E_PARAMNOTFOUND;
     hr = _Recordset_Open( recordset, missing, missing, adOpenStatic, adLockBatchOptimistic, adCmdUnspecified );
-    todo_wine ok( hr == MAKE_ADO_HRESULT( adErrInvalidConnection ), "got %08x\n", hr );
+    ok( hr == MAKE_ADO_HRESULT( adErrInvalidConnection ), "got %08x\n", hr );
 
     hr = _Recordset_get_Fields( recordset, &fields );
     ok( hr == S_OK, "got %08x\n", hr );
@@ -156,6 +159,9 @@ static void test_Recordset(void)
     ok( is_eof( recordset ), "not eof\n" );
     ok( is_bof( recordset ), "not bof\n" );
 
+    hr = _Recordset_Open( recordset, missing, missing, adOpenStatic, adLockBatchOptimistic, adCmdUnspecified );
+    ok( hr == MAKE_ADO_HRESULT( adErrObjectOpen ), "got %08x\n", hr );
+
     state = -1;
     hr = _Recordset_get_State( recordset, &state );
     ok( hr == S_OK, "got %08x\n", hr );




More information about the wine-cvs mailing list