summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qbytearraymatcher.h
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-04-23 09:44:00 (GMT)
committerJoão Abecasis <joao@abecasis.name>2009-04-23 13:28:12 (GMT)
commiteb48c652475a11d32e8ce5fd7d42cea827656f10 (patch)
tree8fd7c10a147d0d8013bf6d3b307e4b2f68e7d983 /src/corelib/tools/qbytearraymatcher.h
parentd913582c270f9f1039a3a788980360aadf39b286 (diff)
downloadQt-eb48c652475a11d32e8ce5fd7d42cea827656f10.zip
Qt-eb48c652475a11d32e8ce5fd7d42cea827656f10.tar.gz
Qt-eb48c652475a11d32e8ce5fd7d42cea827656f10.tar.bz2
Fixes for QByteArrayMatcher
Copy constructor and assignment operator lose data: pointer to content and the length of content also need to be copied over. QByteArrayMatcher::pattern() would return a null byte array if instance was initialized with c-string. Changed default constructor to explicitly initialize pattern length to zero. The bug in the assignment operator is a regression against 4.4.3. Task-number: 251958 Reviewed-by: MariusSO Reviewed-by: paul
Diffstat (limited to 'src/corelib/tools/qbytearraymatcher.h')
-rw-r--r--src/corelib/tools/qbytearraymatcher.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/tools/qbytearraymatcher.h b/src/corelib/tools/qbytearraymatcher.h
index d7f2366..633e92c 100644
--- a/src/corelib/tools/qbytearraymatcher.h
+++ b/src/corelib/tools/qbytearraymatcher.h
@@ -67,7 +67,12 @@ public:
int indexIn(const QByteArray &ba, int from = 0) const;
int indexIn(const char *str, int len, int from = 0) const;
- inline QByteArray pattern() const { return q_pattern; }
+ inline QByteArray pattern() const
+ {
+ if (q_pattern.isNull())
+ return QByteArray((const char*)p.p, p.l);
+ return q_pattern;
+ }
private:
QByteArrayMatcherPrivate *d;