summaryrefslogtreecommitdiff
path: root/libodbcpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-05-27 19:37:07 +0000
committerrandomdan <randomdan@localhost>2010-05-27 19:37:07 +0000
commitc1aa640c7f16369ae088a8ecd9e6f769154b7358 (patch)
tree2e6f0b5803c31688438f460a83db9e4aa874abec /libodbcpp
parentFix output format for double columns (diff)
downloadlibdbpp-odbc-c1aa640c7f16369ae088a8ecd9e6f769154b7358.tar.bz2
libdbpp-odbc-c1aa640c7f16369ae088a8ecd9e6f769154b7358.tar.xz
libdbpp-odbc-c1aa640c7f16369ae088a8ecd9e6f769154b7358.zip
Fix memory leaks and alloc issues
Diffstat (limited to 'libodbcpp')
-rw-r--r--libodbcpp/param.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/libodbcpp/param.cpp b/libodbcpp/param.cpp
index fb839c2..7d5a070 100644
--- a/libodbcpp/param.cpp
+++ b/libodbcpp/param.cpp
@@ -45,12 +45,12 @@ template <class T>
void
ODBC::Param::makeBindLen(T*& p, size_t newLen)
{
- if (bindSize <= newLen) {
+ if (bindSize < newLen) {
if (bindSize) {
- delete p;
+ delete[] p;
}
bindSize = newLen;
- p = new T[newLen];
+ p = new T[newLen + 1];
}
bindLen = newLen;
}
@@ -118,6 +118,7 @@ ODBC::Command::bindParamS(unsigned int i, const unsigned char * val, size_t leng
_Param<SQLCHAR*>* p = Param::makeParam<SQLCHAR*>(params[i]);
p->makeBindLen(p->value, length);
memcpy(p->value, val, length);
+ p->value[length] = '\0';
if (!p->bound) {
p->bind(this->hStmt, i + 1, SQL_C_CHAR, SQL_CHAR, 0, 0, p->value, length);
}