From 2ddc0fcd9bfde1a72846af43967cfd1796156078 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 7 May 2014 09:24:04 +0200 Subject: [PATCH] winrt: DNS lookup: don't have duplicate entries Change-Id: I60ee29bd692f8e385080d4532a0e3230942a2cd3 Reviewed-by: Andrew Knight --- src/network/kernel/qdnslookup_winrt.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/network/kernel/qdnslookup_winrt.cpp b/src/network/kernel/qdnslookup_winrt.cpp index 08f3167a29..e2a5ba2f37 100644 --- a/src/network/kernel/qdnslookup_winrt.cpp +++ b/src/network/kernel/qdnslookup_winrt.cpp @@ -120,6 +120,8 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN unsigned int size; endpointPairs->get_Size(&size); + // endpoint pairs might contain duplicates so we temporarily store addresses in a QSet + QSet addresses; for (unsigned int i = 0; i < size; ++i) { IEndpointPair *endpointpair; endpointPairs->GetAt(i, &endpointpair); @@ -139,9 +141,12 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN remoteHost->Release(); UINT32 length; PCWSTR rawString = name.GetRawBuffer(&length); + addresses.insert(QHostAddress(QString::fromWCharArray(rawString, length))); + } + foreach (const QHostAddress &address, addresses) { QDnsHostAddressRecord record; record.d->name = aceHostname; - record.d->value = QHostAddress(QString::fromWCharArray(rawString, length)); + record.d->value = address; reply->hostAddressRecords.append(record); } }