diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2023-09-04 20:11:17 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2023-09-08 13:30:36 +0200 |
commit | 5e2f22f8a12cf3548beca2245c7ce7bf0a464d53 (patch) | |
tree | d9f7d8f7b51c193c3e6369e9d695b904a46c7377 /src/network/kernel | |
parent | a2e731e7e27d7dd5b43cb9845354ebbbb7b180c4 (diff) |
QHostInfo::lookupHost: do not violate lookupHostImpl preconditions
lookupHostImpl requires either `receiver` or `slotObj` to be non-null.
Since this code path deals with the string-based slots, `slotObj` is
going to be null, therefore check that `receiver` is non-null.
For completeness: also check that `member` is non-null.
Emit a warning (à la QObject::connect) in case the user did something
wrong.
Change-Id: Ic6dcd51d7ddd977b121484369b1aef48844364c5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/network/kernel')
-rw-r--r-- | src/network/kernel/qhostinfo.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 9be6abced0..9e4a3fae83 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -225,6 +225,10 @@ static int nextId() */ int QHostInfo::lookupHost(const QString &name, QT7_ONLY(const) QObject *receiver, const char *member) { + if (!receiver || !member) { + qWarning("QHostInfo::lookupHost: both the receiver and the member to invoke must be non-null"); + return -1; + } return QHostInfo::lookupHostImpl(name, receiver, nullptr, member); } |