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.
This commit is contained in:
@@ -228,6 +228,7 @@ void add_vn_vnvn(float *array_tar, const float *array_src_a, const float *array_
|
||||
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
|
||||
|
@@ -561,6 +561,15 @@ 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)
|
||||
{
|
||||
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);
|
||||
|
@@ -439,7 +439,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
|
||||
|
||||
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 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
|
||||
}
|
||||
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);
|
||||
|
Reference in New Issue
Block a user