Skip to content

Memory leak in Data/ODBC with BLOB #350

@obiltschnig

Description

@obiltschnig

(via support)

Version: 1.5.2 - https://github.com/pocoproject/poco/archive/poco-1.5.2-release.tar.gz

On lines 1030-1033 in Data::ODBC::Preparator.h:

inline void Preparator::prepare(std::size_t pos, const Poco::Data::BLOB&) 
{ 
    prepareVariableLen<Poco::Data::BLOB::ValueType>(pos, SQL_C_BINARY, maxDataSize(pos), DT_CHAR); 
}

The "DT_CHAR" Data::ODBC::Preparator::DataType enum should be changed to "DT_UCHAR" to match the Data::BLOB::ValueType (unsigned char) template parameter.

The current implementation causes a memory leak to occur on lines 666-671 because the cast is of the wrong type resulting in a null pointer which does not get deleted:

template <typename T> 
void deleteCachedArray(std::size_t pos) const 
{ 
    T** p = Poco::AnyCast<T*>(&_values[pos]); 
    if (p) delete [] *p; 
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions