Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElia Sarti <vekoon@gmail.com>2010-03-30 14:13:55 +0400
committerElia Sarti <vekoon@gmail.com>2010-03-30 14:13:55 +0400
commitccdd490957f19ecc9e59bcf9a85ecc25788da99c (patch)
treeddb95b9c20e55081b7d12a1d2cbce50b9efc3031 /source/blender/editors
parentbdea39c809c606cb19641757db8bf0efe67ce11c (diff)
Bugfix for [#21582] Adjusting material color (color picker) crashes
This fixes only the crash, which was due to buffer overrun for col Hex char buffer. It doesn't actually fix the real issue of overflowing the color values up to infinity.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface_regions.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 5f517267805..7f70bfe335a 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -1575,6 +1575,7 @@ void ui_update_block_buts_rgb(uiBlock *block, float *rgb)
}
else if(strcmp(bt->str, "Hex: ")==0) {
float rgb_gamma[3];
+ double intpart;
char col[16];
/* Hex code is assumed to be in sRGB space (coming from other applications, web, etc) */
@@ -1586,6 +1587,10 @@ void ui_update_block_buts_rgb(uiBlock *block, float *rgb)
linearrgb_to_srgb_v3_v3(rgb_gamma, rgb);
}
+ if (rgb_gamma[0] > 1.0f) rgb_gamma[0] = modf(rgb_gamma[0], &intpart);
+ if (rgb_gamma[1] > 1.0f) rgb_gamma[1] = modf(rgb_gamma[1], &intpart);
+ if (rgb_gamma[2] > 1.0f) rgb_gamma[2] = modf(rgb_gamma[2], &intpart);
+
sprintf(col, "%02X%02X%02X", (unsigned int)(rgb_gamma[0]*255.0), (unsigned int)(rgb_gamma[1]*255.0), (unsigned int)(rgb_gamma[2]*255.0));
strcpy(bt->poin, col);