mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 08:14:48 +02:00
Fix 'warning: ‘size_t strlen(const char*)’ reading 1 or more bytes from a region of size 0 [-Wstringop-overread]'
This commit is contained in:
parent
121091ec26
commit
9e93cabdb2
2 changed files with 14 additions and 5 deletions
|
@ -83,7 +83,7 @@ void SockAddr::swap(SockAddr& otherSockAddr) {
|
|||
swap(_socketType, otherSockAddr._socketType);
|
||||
swap(_address, otherSockAddr._address);
|
||||
swap(_port, otherSockAddr._port);
|
||||
|
||||
|
||||
// Swap objects name
|
||||
auto temp = otherSockAddr.objectName();
|
||||
otherSockAddr.setObjectName(objectName());
|
||||
|
@ -135,8 +135,8 @@ bool SockAddr::hasPrivateAddress() const {
|
|||
QDebug operator<<(QDebug debug, const SockAddr& sockAddr) {
|
||||
debug.nospace()
|
||||
<< (sockAddr._socketType != SocketType::Unknown
|
||||
? (SocketTypeToString::socketTypeToString(sockAddr._socketType) + " ").toLocal8Bit().constData() : "")
|
||||
<< sockAddr._address.toString().toLocal8Bit().constData() << ":" << sockAddr._port;
|
||||
? (SocketTypeToString::socketTypeToString(sockAddr._socketType) + " ") : QString(""))
|
||||
<< sockAddr._address.toString() << ":" << sockAddr._port;
|
||||
return debug.space();
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,12 @@ QJsonDocument variantMapToJsonDocument(const QSettings::SettingsMap& map) {
|
|||
case QVariant::ByteArray: {
|
||||
QByteArray a = variant.toByteArray();
|
||||
QString result = QLatin1String("@ByteArray(");
|
||||
result += QString::fromLatin1(a.constData(), a.size());
|
||||
int sz = a.size();
|
||||
if ( sz > 0 ) {
|
||||
// Work around 'warning: ‘size_t strlen(const char*)’ reading 1 or more bytes from a region of size 0 [-Wstringop-overread]'
|
||||
// size() indeed could be zero bytes, so make sure that can't be the case.
|
||||
result += QString::fromLatin1(a.constData(), sz);
|
||||
}
|
||||
result += QLatin1Char(')');
|
||||
object.insert(key, result);
|
||||
break;
|
||||
|
@ -213,7 +218,11 @@ QJsonDocument variantMapToJsonDocument(const QSettings::SettingsMap& map) {
|
|||
}
|
||||
|
||||
QString result = QLatin1String("@Variant(");
|
||||
result += QString::fromLatin1(array.constData(), array.size());
|
||||
int sz = array.size();
|
||||
if ( sz > 0 ) {
|
||||
// See comment in the case handling QVariant::ByteArray
|
||||
result += QString::fromLatin1(array.constData(), sz);
|
||||
}
|
||||
result += QLatin1Char(')');
|
||||
object.insert(key, result);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue