diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-10-04 23:29:02 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-10-04 23:29:02 -0500 |
commit | dc8f5371804c0006ebefc8c0f72be442e6311ce4 (patch) | |
tree | d5108f34d76bf9163659cd2c13201adffdb0614b | |
parent | 3a40adfa9157009fec206bfbc36f514bd08b5af8 (diff) | |
download | qt3-dc8f5371804c0006ebefc8c0f72be442e6311ce4.tar.gz qt3-dc8f5371804c0006ebefc8c0f72be442e6311ce4.zip |
Fix undefined behaviour in TQClipboardWatcher::format
This relates to Bug 1820
-rw-r--r-- | src/kernel/qclipboard_x11.cpp | 15 | ||||
-rw-r--r-- | src/kernel/qmime.cpp | 3 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/kernel/qclipboard_x11.cpp b/src/kernel/qclipboard_x11.cpp index 73cdad4..11fda63 100644 --- a/src/kernel/qclipboard_x11.cpp +++ b/src/kernel/qclipboard_x11.cpp @@ -166,7 +166,7 @@ public: QByteArray getDataInFormat(Atom fmtatom) const; Atom atom; - QValueList<const char *> formatList; + mutable QValueList<const char *> formatList; }; @@ -1304,7 +1304,6 @@ const char* QClipboardWatcher::format( int n ) const // server round trips... static Atom xa_targets = *qt_xdnd_str_to_atom( "TARGETS" ); - QClipboardWatcher *that = (QClipboardWatcher *) this; QByteArray ba = getDataInFormat(xa_targets); if (ba.size() > 0) { Atom *unsorted_target = (Atom *) ba.data(); @@ -1337,21 +1336,21 @@ const char* QClipboardWatcher::format( int n ) const VQDEBUG(" format: %s", qt_xdnd_atom_to_str(target[i])); if ( target[i] == XA_PIXMAP ) - that->formatList.append("image/ppm"); + formatList.append("image/ppm"); else if ( target[i] == XA_STRING ) - that->formatList.append( "text/plain;charset=ISO-8859-1" ); + formatList.append( "text/plain;charset=ISO-8859-1" ); else if ( target[i] == qt_utf8_string ) - that->formatList.append( "text/plain;charset=UTF-8" ); + formatList.append( "text/plain;charset=UTF-8" ); else if ( target[i] == xa_text || target[i] == xa_compound_text ) - that->formatList.append( "text/plain" ); + formatList.append( "text/plain" ); else - that->formatList.append(qt_xdnd_atom_to_str(target[i])); + formatList.append(qt_xdnd_atom_to_str(target[i])); } delete []target; QDEBUG("QClipboardWatcher::format: %d formats available", - int(that->formatList.count())); + int(formatList.count())); } } diff --git a/src/kernel/qmime.cpp b/src/kernel/qmime.cpp index e50757d..d424b2e 100644 --- a/src/kernel/qmime.cpp +++ b/src/kernel/qmime.cpp @@ -139,8 +139,9 @@ bool QMimeSource::provides(const char* mimeType) const { const char* fmt; for (int i=0; (fmt = format(i)); i++) { - if ( !qstricmp(mimeType,fmt) ) + if ( !qstricmp(mimeType,fmt) ) { return TRUE; + } } return FALSE; } |