Fix T103075: Crash when using Limit textures.
Crash only occured when textures was stored in a gray scale GPU texture and was scaled down to fit inside the given limitation. In this case the original number of pixels were packed into the GPU buffer, not taken into account the scaled down image. This resulted in a buffer overflow.
This commit is contained in:
parent
4887401789
commit
f3df7b4fbd
Notes:
blender-bot
2023-02-14 05:50:03 +01:00
Referenced by issue #103075, Regression: crash when resizing grayscale textures (eg. setting "Limit Size" to a small value)
|
@ -223,13 +223,14 @@ static void *imb_gpu_get_data(const ImBuf *ibuf,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int buffer_size = do_rescale ? rescale_size[0] * rescale_size[1] : ibuf->x * ibuf->y;
|
||||
if (is_float_rect) {
|
||||
for (uint64_t i = 0; i < ibuf->x * ibuf->y; i++) {
|
||||
for (uint64_t i = 0; i < buffer_size; i++) {
|
||||
((float *)data_rect)[i] = ((float *)src_rect)[i * 4];
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (uint64_t i = 0; i < ibuf->x * ibuf->y; i++) {
|
||||
for (uint64_t i = 0; i < buffer_size; i++) {
|
||||
((uchar *)data_rect)[i] = ((uchar *)src_rect)[i * 4];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue