Appearance: Use BString::SetToFormat instead of sprintf to create hex color.
Fixes a GCC7 Werror about (potential) format overflow.
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <MessageRunner.h>
|
#include <MessageRunner.h>
|
||||||
|
#include <String.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
@@ -227,11 +228,11 @@ ColorPreview::SetMode(bool rectangle)
|
|||||||
void
|
void
|
||||||
ColorPreview::_DragColor(BPoint where)
|
ColorPreview::_DragColor(BPoint where)
|
||||||
{
|
{
|
||||||
char hexString[7];
|
BString hexStr;
|
||||||
sprintf(hexString, "#%.2X%.2X%.2X", fColor.red, fColor.green, fColor.blue);
|
hexStr.SetToFormat("#%.2X%.2X%.2X", fColor.red, fColor.green, fColor.blue);
|
||||||
|
|
||||||
BMessage message(B_PASTE);
|
BMessage message(B_PASTE);
|
||||||
message.AddData("text/plain", B_MIME_TYPE, &hexString, sizeof(hexString));
|
message.AddData("text/plain", B_MIME_TYPE, hexStr.String(), hexStr.Length());
|
||||||
message.AddData("RGBColor", B_RGB_COLOR_TYPE, &fColor, sizeof(fColor));
|
message.AddData("RGBColor", B_RGB_COLOR_TYPE, &fColor, sizeof(fColor));
|
||||||
|
|
||||||
BRect rect(0.0f, 0.0f, 20.0f, 20.0f);
|
BRect rect(0.0f, 0.0f, 20.0f, 20.0f);
|
||||||
|
|||||||
Reference in New Issue
Block a user