Skip to content

Commit 1e7534e

Browse files
authored
Merge pull request #297 from fdcastel/fix/sqlcopydesc-empty-descriptor-segv
Fix SIGSEGV in SQLCopyDesc when source descriptor is empty
2 parents ca97f46 + e4146a5 commit 1e7534e

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

OdbcDesc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ SQLRETURN OdbcDesc::operator =(OdbcDesc &sour)
210210

211211
for ( int n = 0 ; n <= headCount ; n++ )
212212
{
213-
DescRecord *srcrec = sour.records[n];
213+
// sour.records is NULL for an empty source — guard like the other loops in this file.
214+
DescRecord *srcrec = sour.records ? sour.records[n] : NULL;
214215
DescRecord &rec = *getDescRecord ( n );
215216

216217
if ( srcrec )

tests/test_phase7_crusher_fixes.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
class CopyDescCrashTest : public OdbcConnectedTest {};
1313

1414
TEST_F(CopyDescCrashTest, CopyEmptyARDDoesNotCrash) {
15-
GTEST_SKIP() << "Requires Phase 7: ODBC Crusher-identified bug fixes (not yet merged)";
1615
// Allocate two statements with no bindings (empty ARDs)
1716
SQLHSTMT stmt1 = AllocExtraStmt();
1817
SQLHSTMT stmt2 = AllocExtraStmt();
@@ -49,7 +48,6 @@ TEST_F(CopyDescCrashTest, CopyEmptyARDDoesNotCrash) {
4948
}
5049

5150
TEST_F(CopyDescCrashTest, CopyEmptyToExplicitDescriptor) {
52-
GTEST_SKIP() << "Requires Phase 7: ODBC Crusher-identified bug fixes (not yet merged)";
5351
// Allocate an explicit descriptor
5452
SQLHDESC hExplicit = SQL_NULL_HDESC;
5553
SQLRETURN ret = SQLAllocHandle(SQL_HANDLE_DESC, hDbc, &hExplicit);
@@ -70,7 +68,6 @@ TEST_F(CopyDescCrashTest, CopyEmptyToExplicitDescriptor) {
7068
}
7169

7270
TEST_F(CopyDescCrashTest, CopyPopulatedThenEmpty) {
73-
GTEST_SKIP() << "Requires Phase 7: ODBC Crusher-identified bug fixes (not yet merged)";
7471
// First, populate an explicit descriptor by copying a populated ARD
7572
SQLINTEGER val = 0;
7673
SQLLEN ind = 0;

0 commit comments

Comments
 (0)