[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27860] trunk/blender/source/blender/ editors/interface/interface_regions.c: Bugfix for [#21582] Adjusting material color (color picker) crashes

Elia Sarti vekoon at gmail.com
Tue Mar 30 12:13:55 CEST 2010


Revision: 27860
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27860
Author:   vekoon
Date:     2010-03-30 12:13:55 +0200 (Tue, 30 Mar 2010)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_regions.c

Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c	2010-03-30 09:57:58 UTC (rev 27859)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c	2010-03-30 10:13:55 UTC (rev 27860)
@@ -1575,6 +1575,7 @@
 		}
 		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 @@
 				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);





More information about the Bf-blender-cvs mailing list