diff options
-rw-r--r-- | src/corelib/global/qlogging.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 5f95bbf149..e80e5b72d5 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1338,11 +1338,8 @@ void QMessagePattern::setPattern(const QString &pattern) .arg(lexeme); } } else { - char *literal = new char[lexeme.size() + 1]; - strncpy(literal, lexeme.toLatin1().constData(), lexeme.size()); - literal[lexeme.size()] = '\0'; - literalsVar.emplace_back(literal); - tokens[i] = literal; + using UP = std::unique_ptr<char[]>; + tokens[i] = literalsVar.emplace_back(UP(qstrdup(lexeme.toLatin1().constData()))).get(); } } if (nestedIfError) |