diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-07-02 13:36:48 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-20 05:07:09 +0200 |
commit | 4b3acf5aff76344aab4584b5c54b74d189b19246 (patch) | |
tree | c38f90f1711a789f22ce4fec0e53e93df4f4eaa0 | |
parent | 6130bb22e754eec132e49e5f254bcedc935e69b0 (diff) |
QUrl: Make sure we don't return a dangling pointer from parseIpFuture
Change-Id: I54bf8d0fe72b8db8d158899ee4525c8d067272b8
Reviewed-by: David Faure (KDE) <faure@kde.org>
-rw-r--r-- | src/corelib/io/qurl.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 3c8483029a..30320c9cc2 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -1096,6 +1096,7 @@ static const QChar *parseIpFuture(QString &host, const QChar *begin, const QChar "-._~"; // unreserved // the brackets and the "v" have been checked + const QChar *const origBegin = begin; if (begin[3].unicode() != '.') return &begin[3]; if ((begin[2].unicode() >= 'A' && begin[2].unicode() <= 'F') || @@ -1128,12 +1129,12 @@ static const QChar *parseIpFuture(QString &host, const QChar *begin, const QChar else if (begin->unicode() < 0x80 && strchr(acceptable, begin->unicode()) != 0) host += *begin; else - return begin; + return decoded.isEmpty() ? begin : &origBegin[2]; } host += QLatin1Char(']'); return 0; } - return &begin[2]; + return &origBegin[2]; } // ONLY the IPv6 address is parsed here, WITHOUT the brackets |