From f10c9f20e8d32330c9f4ab46a638ab5556cb61b8 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 15 Nov 2011 11:57:06 +0200 Subject: Truncate excess QString and QByteArray data mapped to CHAR and RAW types --- odb/qt/basic/oracle/qbyte-array-traits.hxx | 7 +++---- odb/qt/basic/oracle/qstring-traits.hxx | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/odb/qt/basic/oracle/qbyte-array-traits.hxx b/odb/qt/basic/oracle/qbyte-array-traits.hxx index 58807b9..3d99cd7 100644 --- a/odb/qt/basic/oracle/qbyte-array-traits.hxx +++ b/odb/qt/basic/oracle/qbyte-array-traits.hxx @@ -59,11 +59,10 @@ namespace odb n = static_cast (v.size ()); - //@@ Assert or throw? - // - assert (n <= c); + if (n > c) + n = c; - std::memcpy (b, v.data (), n); + std::memcpy (b, v.constData (), n); } } }; diff --git a/odb/qt/basic/oracle/qstring-traits.hxx b/odb/qt/basic/oracle/qstring-traits.hxx index 729de62..c0b6775 100644 --- a/odb/qt/basic/oracle/qstring-traits.hxx +++ b/odb/qt/basic/oracle/qstring-traits.hxx @@ -53,13 +53,13 @@ namespace odb is_null = false; const QByteArray& a (v.toUtf8 ()); + n = static_cast (a.size ()); - //@@ Assert or throw? - // - assert (n <= c); + if (n > c) + n = c; - std::memcpy (b, a.data (), n); + std::memcpy (b, a.constData (), n); } } }; -- cgit v1.1