Skip to content

Commit

Permalink
Fix wrong reply size in NativeMessagingBase
Browse files Browse the repository at this point in the history
* Using length() on QString won't return correct size in bytes when string
contains UTF-8 chars.
  • Loading branch information
Olivier Le Moal authored and phoerious committed Mar 13, 2018
1 parent 970cedf commit 3353b32
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/browser/NativeMessagingBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ void NativeMessagingBase::sendReply(const QJsonObject& json)
void NativeMessagingBase::sendReply(const QString& reply)
{
if (!reply.isEmpty()) {
uint len = reply.length();
QByteArray bytes = reply.toUtf8();
uint len = bytes.size();
std::cout << char(((len>>0) & 0xFF)) << char(((len>>8) & 0xFF)) << char(((len>>16) & 0xFF)) << char(((len>>24) & 0xFF));
std::cout << reply.toStdString() << std::flush;
}
Expand Down

0 comments on commit 3353b32

Please sign in to comment.