diff options
author | Jeroen Bakker <jeroen@blender.org> | 2021-12-10 12:37:46 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-12-10 12:37:46 +0300 |
commit | fcf8fc3eaa34996cb89b156ba15ced767dc42f08 (patch) | |
tree | 99124ed80f9bfa02bf1f6de9ff0cb899db78a424 /source/blender/imbuf/IMB_imbuf.h | |
parent | 57f46b9d5f370dfacc92786dab596060400a21a8 (diff) |
Fix Crash: Loading Huge Images.
When loading huge images (30k) blender crashed with a buffer overflow.
The reason is that determine the length of a buffer was done in 32bit
precision and afterwards stored in 64 bit precision.
This patch adds a new function to do the correct calculation in 64bit.
It should be added to other sections in blender as well. But that should
be tested on a per case situation.
Diffstat (limited to 'source/blender/imbuf/IMB_imbuf.h')
-rw-r--r-- | source/blender/imbuf/IMB_imbuf.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 6e8bed148d5..daa3dbd1f1a 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -201,6 +201,17 @@ bool addzbuffloatImBuf(struct ImBuf *ibuf); size_t IMB_get_size_in_memory(struct ImBuf *ibuf); /** + * \brief Get the length of the rect of the given image buffer in terms of pixels. + * + * This is the width * the height of the image buffer. + * This function is preferred over `ibuf->x * ibuf->y` due to overflow issues when + * working with large resolution images (30kx30k). + * + * \attention Defined in allocimbuf.c + */ +size_t IMB_get_rect_len(const struct ImBuf *ibuf); + +/** * * \attention Defined in rectop.c */ |