[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41479] branches/soc-2011-onion-uv-tools/ source/blender/gpu/intern/gpu_draw.c: Correct incorrect memory free and crash reported by troubled.
Antony Riakiotakis
kalast at gmail.com
Wed Nov 2 23:44:33 CET 2011
Revision: 41479
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41479
Author: psy-fi
Date: 2011-11-02 22:44:32 +0000 (Wed, 02 Nov 2011)
Log Message:
-----------
Correct incorrect memory free and crash reported by troubled. Thanks a lot!
Modified Paths:
--------------
branches/soc-2011-onion-uv-tools/source/blender/gpu/intern/gpu_draw.c
Modified: branches/soc-2011-onion-uv-tools/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- branches/soc-2011-onion-uv-tools/source/blender/gpu/intern/gpu_draw.c 2011-11-02 22:00:22 UTC (rev 41478)
+++ branches/soc-2011-onion-uv-tools/source/blender/gpu/intern/gpu_draw.c 2011-11-02 22:44:32 UTC (rev 41479)
@@ -433,7 +433,7 @@
float *color_corrected_frect = NULL;
short texwindx, texwindy, texwinsx, texwinsy;
/*flag to determine whether high resolution format is used*/
- int useHighPrecisionTex = FALSE;
+ int useHighPrecisionTex = FALSE, doColorConversion = FALSE;
/* initialize tile mode and number of repeats */
GTS.ima = ima;
@@ -490,12 +490,16 @@
a high precision format only if it is available*/
useHighPrecisionTex = TRUE;
}
+ if(ibuf->profile == IB_PROFILE_LINEAR_RGB){
+ doColorConversion = TRUE;
+ }
+
if(ibuf->rect==NULL){
IMB_rect_from_float(ibuf);
}
}
-
+
/* currently, tpage refresh is used by ima sequences */
if(ima->tpageflag & IMA_TPAGE_REFRESH) {
GPU_free_image(ima);
@@ -530,7 +534,7 @@
if(useHighPrecisionTex){
/* We may also need a color corrected float image. Dithering will not apply since it's high precision */
- if(ibuf->profile == IB_PROFILE_LINEAR_RGB){
+ if(doColorConversion){
color_corrected_frect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(float)*4, "floar_buf_col_cor");
IMB_float_color_corrected_from_float_rect(ibuf, color_corrected_frect);
frect= color_corrected_frect + texwinsy*ibuf->x + texwinsx;
@@ -552,8 +556,8 @@
rect= ibuf->rect;
if(useHighPrecisionTex){
/* We may also need a color corrected float image. Dithering will not apply since it's high precision */
- if(ibuf->profile == IB_PROFILE_LINEAR_RGB){
- frect = color_corrected_frect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(float)*4, "floar_buf_col_cor");
+ if(doColorConversion){
+ frect = color_corrected_frect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(*color_corrected_frect)*4, "floar_buf_col_cor");
IMB_float_color_corrected_from_float_rect(ibuf, color_corrected_frect);
}else{
frect= ibuf->rect_float;
@@ -606,9 +610,11 @@
if(useHighPrecisionTex)
{
- fscalerect= MEM_mallocN(rectw*recth*sizeof(float)*4, "fscalerect");
+ fscalerect= MEM_mallocN(rectw*recth*sizeof(*fscalerect)*4, "fscalerect");
gluScaleImage(GL_RGBA, tpx, tpy, GL_FLOAT, frect, rectw, recth, GL_FLOAT, fscalerect);
- MEM_freeN(frect);
+ /* Or frect will refer to ibuf->rect_float. We don't want to free that */
+ if(doColorConversion)
+ MEM_freeN(frect);
frect = fscalerect;
fscalerect = NULL;
}
@@ -652,7 +658,7 @@
if (tilerect)
MEM_freeN(tilerect);
if (ftilerect)
- MEM_freeN(ftilerect);
+ MEM_freeN(ftilerect);
if (scalerect)
MEM_freeN(scalerect);
if (fscalerect)
More information about the Bf-blender-cvs
mailing list