Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix piecewise crash
  • Loading branch information
uclaros committed May 1, 2021
1 parent f12317d commit cbdd166
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/providers/oracle/ocispatial/qsql_ocispatial.cpp
Expand Up @@ -1549,6 +1549,7 @@ int QOCISpatialCols::readPiecewise( QVector<QVariant> &values, int index )
int r = 0;
bool nullField;

bool firstPiece = true;
do
{
r = OCIStmtGetPieceInfo( d->sql, d->err, reinterpret_cast<void **>( &dfn ), &typep,
Expand Down Expand Up @@ -1589,20 +1590,21 @@ int QOCISpatialCols::readPiecewise( QVector<QVariant> &values, int index )
{
if ( isStringField )
{
QString str = values.at( fieldNum + index ).toString();
QString str = firstPiece ? QString() : values.at( fieldNum + index ).toString();
str += QString( reinterpret_cast<const QChar *>( col ), chunkSize / 2 );
values[fieldNum + index] = str;
fieldInf[fieldNum].ind = 0;
}
else
{
QByteArray ba = values.at( fieldNum + index ).toByteArray();
QByteArray ba = firstPiece ? QByteArray() : values.at( fieldNum + index ).toByteArray();
int sz = ba.size();
ba.resize( sz + chunkSize );
memcpy( ba.data() + sz, reinterpret_cast<char *>( col ), chunkSize );
values[fieldNum + index] = ba;
fieldInf[fieldNum].ind = 0;
}
firstPiece = false;
}
}
while ( status == OCI_SUCCESS_WITH_INFO || status == OCI_NEED_DATA );
Expand Down Expand Up @@ -3413,7 +3415,6 @@ bool QOCISpatialResult::gotoNext( QSqlCachedResult::ValueCache &values, int inde
// need to read piecewise before assigning values
if ( r == OCI_SUCCESS && piecewise )
{
values.clear();
r = d->cols->readPiecewise( values, index );
}

Expand Down

0 comments on commit cbdd166

Please sign in to comment.