summaryrefslogtreecommitdiffstats
path: root/kdecore/ksycoca.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-01-26 22:23:30 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-01-26 22:23:30 +0000
commit946bde4a62fa9c4c47315defb2e31cf54d821246 (patch)
tree4c8722f3db4e1cc5800519d00ccd30c60c50dd3d /kdecore/ksycoca.cpp
parenta20928b6bfae18a41bb42b85e10f73fb63548ccc (diff)
downloadtdelibs-946bde4a62fa9c4c47315defb2e31cf54d821246.tar.gz
tdelibs-946bde4a62fa9c4c47315defb2e31cf54d821246.zip
Patch a few buffer overrun problems and odd crash potentials
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1217371 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdecore/ksycoca.cpp')
-rw-r--r--kdecore/ksycoca.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/kdecore/ksycoca.cpp b/kdecore/ksycoca.cpp
index f6b9ffa6a..255763ef0 100644
--- a/kdecore/ksycoca.cpp
+++ b/kdecore/ksycoca.cpp
@@ -87,7 +87,7 @@ int KSycoca::version()
// Read-only constructor
KSycoca::KSycoca()
- : DCOPObject("ksycoca"), m_lstFactories(0), m_str(0), bNoDatabase(false),
+ : DCOPObject("ksycoca"), m_lstFactories(0), m_str(0), m_barray(0), bNoDatabase(false),
m_sycoca_size(0), m_sycoca_mmap(0), m_timeStamp(0)
{
d = new KSycocaPrivate;
@@ -110,6 +110,7 @@ bool KSycoca::openDatabase( bool openDummyIfNotFound )
m_sycoca_mmap = 0;
m_str = 0;
+ m_barray = 0;
TQString path;
TQCString ksycoca_env = getenv("KDESYCOCA");
if (ksycoca_env.isEmpty())
@@ -154,9 +155,9 @@ bool KSycoca::openDatabase( bool openDummyIfNotFound )
#ifdef HAVE_MADVISE
(void) madvise((char*)m_sycoca_mmap, m_sycoca_size, MADV_WILLNEED);
#endif
- TQByteArray b_array;
- b_array.setRawData(m_sycoca_mmap, m_sycoca_size);
- TQBuffer *buffer = new TQBuffer( b_array );
+ m_barray = new TQByteArray();
+ m_barray->setRawData(m_sycoca_mmap, m_sycoca_size);
+ TQBuffer *buffer = new TQBuffer( *m_barray );
buffer->open(IO_ReadWrite);
m_str = new TQDataStream( buffer);
}
@@ -195,7 +196,7 @@ bool KSycoca::openDatabase( bool openDummyIfNotFound )
// Read-write constructor - only for KBuildSycoca
KSycoca::KSycoca( bool /* dummy */ )
- : DCOPObject("ksycoca_building"), m_lstFactories(0), m_str(0), bNoDatabase(false),
+ : DCOPObject("ksycoca_building"), m_lstFactories(0), m_str(0), m_barray(0), bNoDatabase(false),
m_sycoca_size(0), m_sycoca_mmap(0)
{
d = new KSycocaPrivate;
@@ -226,13 +227,13 @@ KSycoca::~KSycoca()
void KSycoca::closeDatabase()
{
- TQIODevice *device = 0;
+ QIODevice *device = 0;
if (m_str)
- device = m_str->tqdevice();
+ device = m_str->device();
#ifdef HAVE_MMAP
if (device && m_sycoca_mmap)
{
- TQBuffer *buf = (TQBuffer *) device;
+ TQBuffer *buf = static_cast<TQBuffer*>(device);
buf->buffer().resetRawData(m_sycoca_mmap, m_sycoca_size);
// Solaris has munmap(char*, size_t) and everything else should
// be happy with a char* for munmap(void*, size_t)
@@ -246,6 +247,7 @@ void KSycoca::closeDatabase()
delete device;
if (TQT_TQIODEVICE(d->database) != device)
delete d->database;
+ if (m_barray) delete m_barray;
device = 0;
d->database = 0;
// It is very important to delete all factories here