Fix the crash during priority menu building - use the snprintf instead of sprintf.
The buffer 32 + 20 bytes become too small for localized strings - increase it too. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40708 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -76,7 +76,6 @@ PriorityMenu::BuildMenu()
|
|||||||
{
|
{
|
||||||
BMenuItem* item;
|
BMenuItem* item;
|
||||||
BMessage* message;
|
BMessage* message;
|
||||||
char name[B_OS_NAME_LENGTH + 20];
|
|
||||||
long found = false;
|
long found = false;
|
||||||
|
|
||||||
for (long index = 0; ; index++) {
|
for (long index = 0; ; index++) {
|
||||||
@@ -91,12 +90,16 @@ PriorityMenu::BuildMenu()
|
|||||||
message = new BMessage('PrTh');
|
message = new BMessage('PrTh');
|
||||||
message->AddInt32("thread", fThreadID);
|
message->AddInt32("thread", fThreadID);
|
||||||
message->AddInt32("priority", priority->priority);
|
message->AddInt32("priority", priority->priority);
|
||||||
sprintf(name, B_TRANSLATE("%s [%d]"), priority->name,
|
BString name;
|
||||||
(int)priority->priority);
|
const size_t size = B_OS_NAME_LENGTH * 4;
|
||||||
item = new BMenuItem(name, message);
|
snprintf(name.LockBuffer(size), size,
|
||||||
|
B_TRANSLATE("%s [%d]"), priority->name, (int)priority->priority);
|
||||||
|
name.UnlockBuffer();
|
||||||
|
item = new BMenuItem(name.String(), message);
|
||||||
item->SetTarget(gPCView);
|
item->SetTarget(gPCView);
|
||||||
if (fPriority == priority->priority)
|
if (fPriority == priority->priority)
|
||||||
found = true, item->SetMarked(true);
|
found = true, item->SetMarked(true);
|
||||||
AddItem(item);
|
AddItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user