mirror of
https://github.com/silverqx/TinyORM.git
synced 2025-12-30 15:29:36 -06:00
drivers bugfix index bounds check
This commit is contained in:
@@ -89,7 +89,7 @@ namespace Orm::Drivers::MySql
|
||||
QVariant getValueForPrepared(ResultFieldsSizeType index) const;
|
||||
|
||||
/*! Throw an exception if an index for result fields vector is out of bounds. */
|
||||
void throwIfBadResultFieldsIndex(ResultFieldsSizeType index) const;
|
||||
void throwIfBadResultFieldsIndex(size_type index) const;
|
||||
|
||||
/* Data members */
|
||||
/* Common for both */
|
||||
|
||||
@@ -419,10 +419,10 @@ QVariant MySqlResult::data(const size_type index) const
|
||||
{
|
||||
Q_D(const MySqlResult);
|
||||
|
||||
const auto idx = static_cast<MySqlResultPrivate::ResultFieldsSizeType>(index);
|
||||
|
||||
// Throw an exception if an index for result fields vector is out of bounds
|
||||
d->throwIfBadResultFieldsIndex(idx);
|
||||
d->throwIfBadResultFieldsIndex(index);
|
||||
|
||||
const auto idx = static_cast<MySqlResultPrivate::ResultFieldsSizeType>(index);
|
||||
|
||||
if (d->preparedQuery)
|
||||
return d->getValueForPrepared(idx);
|
||||
@@ -434,10 +434,10 @@ bool MySqlResult::isNull(const size_type index) const
|
||||
{
|
||||
Q_D(const MySqlResult);
|
||||
|
||||
const auto idx = static_cast<MySqlResultPrivate::ResultFieldsSizeType>(index);
|
||||
|
||||
// Throw an exception if an index for result fields vector is out of bounds
|
||||
d->throwIfBadResultFieldsIndex(idx);
|
||||
d->throwIfBadResultFieldsIndex(index);
|
||||
|
||||
const auto idx = static_cast<MySqlResultPrivate::ResultFieldsSizeType>(index);
|
||||
|
||||
/* MyField::isNull is populated for prepared statements only.
|
||||
The row/result set/data must be fetched first to obtain the correct result. ❗ */
|
||||
|
||||
@@ -368,12 +368,12 @@ QVariant MySqlResultPrivate::getValueForPrepared(const ResultFieldsSizeType inde
|
||||
}
|
||||
|
||||
void
|
||||
MySqlResultPrivate::throwIfBadResultFieldsIndex(const ResultFieldsSizeType index) const
|
||||
MySqlResultPrivate::throwIfBadResultFieldsIndex(const size_type index) const
|
||||
{
|
||||
const auto fieldsCount = resultFields.size();
|
||||
|
||||
// Nothing to do
|
||||
if (index >= 0 || index < fieldsCount)
|
||||
if (index >= 0 || index < static_cast<size_type>(fieldsCount))
|
||||
return;
|
||||
|
||||
throw Exceptions::OutOfRangeError(
|
||||
|
||||
Reference in New Issue
Block a user