mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
use QSTACKARRAY() in QHostInfo::localDomainName()
fixes assert in QUrl::fromAce() Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
361285c27a
commit
e9e088f5c8
1 changed files with 8 additions and 7 deletions
|
@ -198,8 +198,9 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
|
|||
QString QHostInfo::localHostName()
|
||||
{
|
||||
static long size_max = sysconf(_SC_HOST_NAME_MAX);
|
||||
if (size_max == -1)
|
||||
if (size_max == -1) {
|
||||
size_max = _POSIX_HOST_NAME_MAX;
|
||||
}
|
||||
QSTACKARRAY(char, gethostbuff, size_max);
|
||||
if (Q_LIKELY(::gethostname(gethostbuff, size_max) == 0)) {
|
||||
return QString::fromLocal8Bit(gethostbuff);
|
||||
|
@ -212,16 +213,16 @@ QString QHostInfo::localDomainName()
|
|||
#if defined(QT_HAVE_GETDOMAINNAME)
|
||||
// thread-safe
|
||||
static long size_max = sysconf(_SC_HOST_NAME_MAX);
|
||||
if (size_max == -1)
|
||||
if (size_max == -1) {
|
||||
size_max = _POSIX_HOST_NAME_MAX;
|
||||
Q_ASSERT(size_max >= 1);
|
||||
QByteArray getdomainbuff(size_max, Qt::Uninitialized);
|
||||
if (Q_LIKELY(::getdomainname(getdomainbuff.data(), getdomainbuff.size()) == 0)) {
|
||||
if (getdomainbuff == "(none)") {
|
||||
}
|
||||
QSTACKARRAY(char, getdomainbuff, size_max);
|
||||
if (Q_LIKELY(::getdomainname(getdomainbuff, sizeof(getdomainbuff)) == 0)) {
|
||||
if (qstrncmp("(none)", getdomainbuff, 6) == 0) {
|
||||
// not set
|
||||
return QString();
|
||||
}
|
||||
return QUrl::fromAce(getdomainbuff);
|
||||
return QUrl::fromAce(QByteArray(getdomainbuff));
|
||||
}
|
||||
return QString();
|
||||
#else
|
||||
|
|
Loading…
Add table
Reference in a new issue