From 1831e7f802d1bdba33f320c21f29df02d647ead8 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 22 Mar 2011 17:59:05 +0000 Subject: Ensure parameters of async function calls stay in scope Calling symbian asynchronous functions with parameters on the stack, even "in" parameters is unsafe. If the server is blocked on another operation, then it will not read the parameters until later (at which time the stack is invalid) Reviewed-by: Markus Goetz --- src/network/kernel/qhostinfo_p.h | 4 ++++ src/network/kernel/qhostinfo_symbian.cpp | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index bff5fc4..71c191f 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -249,12 +249,16 @@ private: private: const QString iHostName; + QString iEncodedHostName; + TPtrC iHostNamePtr; RSocketServ& iSocketServ; RHostResolver iHostResolver; QSharedPointer iNetworkSession; TNameEntry iNameResult; + TInetAddr IpAdd; + QHostAddress iAddress; QHostInfo iResults; diff --git a/src/network/kernel/qhostinfo_symbian.cpp b/src/network/kernel/qhostinfo_symbian.cpp index c969748..c1457fd 100644 --- a/src/network/kernel/qhostinfo_symbian.cpp +++ b/src/network/kernel/qhostinfo_symbian.cpp @@ -259,7 +259,6 @@ void QSymbianHostResolver::requestHostLookup() if (iAddress.setAddress(iHostName)) { // Reverse lookup - TInetAddr IpAdd; IpAdd.Input(qt_QString2TPtrC(iHostName)); // Asynchronous request. @@ -279,9 +278,11 @@ void QSymbianHostResolver::requestHostLookup() err = KErrArgument; } else { + iEncodedHostName = QString::fromLatin1(aceHostname); + iHostNamePtr.Set(qt_QString2TPtrC(iEncodedHostName)); // Asynchronous request. - iHostResolver.GetByName(qt_QString2TPtrC(QString::fromLatin1(aceHostname)), iNameResult, iStatus); + iHostResolver.GetByName(iHostNamePtr, iNameResult, iStatus); iState = EGetByName; } } -- cgit v0.12