From e6b48d2c0f880d0eaaa6b1fca1781cbcc7b43903 Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Sat, 26 Feb 2011 23:10:20 +0000 Subject: [PATCH] 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 --- src/apps/processcontroller/PriorityMenu.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/apps/processcontroller/PriorityMenu.cpp b/src/apps/processcontroller/PriorityMenu.cpp index 3268253d63..b791760f4b 100644 --- a/src/apps/processcontroller/PriorityMenu.cpp +++ b/src/apps/processcontroller/PriorityMenu.cpp @@ -76,7 +76,6 @@ PriorityMenu::BuildMenu() { BMenuItem* item; BMessage* message; - char name[B_OS_NAME_LENGTH + 20]; long found = false; for (long index = 0; ; index++) { @@ -91,12 +90,16 @@ PriorityMenu::BuildMenu() message = new BMessage('PrTh'); message->AddInt32("thread", fThreadID); message->AddInt32("priority", priority->priority); - sprintf(name, B_TRANSLATE("%s [%d]"), priority->name, - (int)priority->priority); - item = new BMenuItem(name, message); + BString name; + const size_t size = B_OS_NAME_LENGTH * 4; + 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); if (fPriority == priority->priority) found = true, item->SetMarked(true); AddItem(item); } } +