[Bf-blender-cvs] [f3df7b4fbde] master: Fix T103075: Crash when using Limit textures.

Jeroen Bakker noreply at git.blender.org
Mon Jan 9 09:48:00 CET 2023


Commit: f3df7b4fbde52291984ea6cf6e110ffc6395ac30
Author: Jeroen Bakker
Date:   Mon Jan 9 09:44:54 2023 +0100
Branches: master
https://developer.blender.org/rBf3df7b4fbde52291984ea6cf6e110ffc6395ac30

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.

===================================================================

M	source/blender/imbuf/intern/util_gpu.c

===================================================================

diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.c
index eda89c7296d..c71a867669a 100644
--- a/source/blender/imbuf/intern/util_gpu.c
+++ b/source/blender/imbuf/intern/util_gpu.c
@@ -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];
       }
     }



More information about the Bf-blender-cvs mailing list