[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45900] trunk/blender/source/blender: fix for invalid use of memset when loading tiff images
Campbell Barton
ideasman42 at gmail.com
Tue Apr 24 01:57:17 CEST 2012
Revision: 45900
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45900
Author: campbellbarton
Date: 2012-04-23 23:57:17 +0000 (Mon, 23 Apr 2012)
Log Message:
-----------
fix for invalid use of memset when loading tiff images
- memset(..., 1.0); // isnt valid
- memset(pointer, sizeof(pointer)) // was using the sizeof the pointer, not the size of the array, since this was to fill in alpha values it was obviously wrong.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_math_vector.h
trunk/blender/source/blender/blenlib/intern/math_vector.c
trunk/blender/source/blender/imbuf/intern/tiff.c
Modified: trunk/blender/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_vector.h 2012-04-23 23:01:03 UTC (rev 45899)
+++ trunk/blender/source/blender/blenlib/BLI_math_vector.h 2012-04-23 23:57:17 UTC (rev 45900)
@@ -228,6 +228,7 @@
void sub_vn_vn(float *array_tar, const float *array_src, const int size);
void sub_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_src_b, const int size);
void fill_vn_i(int *array_tar, const int size, const int val);
+void fill_vn_ushort(unsigned short *array_tar, const int size, const unsigned short val);
void fill_vn_fl(float *array_tar, const int size, const float val);
#ifdef __cplusplus
Modified: trunk/blender/source/blender/blenlib/intern/math_vector.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_vector.c 2012-04-23 23:01:03 UTC (rev 45899)
+++ trunk/blender/source/blender/blenlib/intern/math_vector.c 2012-04-23 23:57:17 UTC (rev 45900)
@@ -561,6 +561,15 @@
}
}
+void fill_vn_ushort(unsigned short *array_tar, const int size, const unsigned short val)
+{
+ unsigned short *tar = array_tar + (size - 1);
+ int i = size;
+ while (i--) {
+ *(tar--) = val;
+ }
+}
+
void fill_vn_fl(float *array_tar, const int size, const float val)
{
float *tar = array_tar + (size - 1);
Modified: trunk/blender/source/blender/imbuf/intern/tiff.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/tiff.c 2012-04-23 23:01:03 UTC (rev 45899)
+++ trunk/blender/source/blender/imbuf/intern/tiff.c 2012-04-23 23:57:17 UTC (rev 45900)
@@ -439,7 +439,7 @@
if (bitspersample == 32) {
if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */
- memset(fbuf, 1.0, sizeof(fbuf));
+ fill_vn_fl(fbuf, ibuf->x, 1.0f);
else
success |= TIFFReadScanline(image, fbuf, row, chan);
scanline_separate_32bit(tmpibuf->rect_float+ib_offset, fbuf, ibuf->x, chan);
@@ -447,7 +447,7 @@
}
else if (bitspersample == 16) {
if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */
- memset(sbuf, 65535, sizeof(sbuf));
+ fill_vn_ushort(sbuf, ibuf->x, 65535);
else
success |= TIFFReadScanline(image, sbuf, row, chan);
scanline_separate_16bit(tmpibuf->rect_float+ib_offset, sbuf, ibuf->x, chan);
More information about the Bf-blender-cvs
mailing list