Include the terminating 0 byte when adding as string type. Otherwise someone

reading the message as an actual string will run into problems.
Should fix #4697.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33442 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2009-10-05 13:38:27 +00:00
parent 821b62c231
commit 81c431d23d
2 changed files with 3 additions and 3 deletions

View File

@ -735,7 +735,7 @@ KeyboardDevice::_ControlThread()
if (numBytes > 0) {
for (int i = 0; i < numBytes; i++)
msg->AddInt8("byte", (int8)string[i]);
msg->AddData("bytes", B_STRING_TYPE, string, numBytes);
msg->AddData("bytes", B_STRING_TYPE, string, numBytes + 1);
if (rawNumBytes <= 0) {
rawNumBytes = 1;

View File

@ -1117,7 +1117,7 @@ FrameMoved(origin);
ssize_t bytes;
if (msg->FindData("bytes", B_STRING_TYPE,
(const void**)&string, &bytes) == B_OK) {
view->KeyDown(string, bytes);
view->KeyDown(string, bytes - 1);
}
} else
target->MessageReceived(msg);
@ -1133,7 +1133,7 @@ FrameMoved(origin);
ssize_t bytes;
if (msg->FindData("bytes", B_STRING_TYPE,
(const void**)&string, &bytes) == B_OK) {
view->KeyUp(string, bytes);
view->KeyUp(string, bytes - 1);
}
} else
target->MessageReceived(msg);