Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-12-16 14:42:48 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-12-16 14:51:27 +0400
commitc193dbe30b40beb435d6edde7117469f4706f98e (patch)
tree8df263e9d706f9a8f47d9b0210597d6ad33c22e4 /source/blender/imbuf/intern/allocimbuf.c
parenta2543ee43dc6a35b36a8feda83679bf3e22e218d (diff)
Fix T37826: Opening a new image in the image editor
Cast dimensions to size_t before multiplication. Also made add_ibuf_size survive cases when image buffer allocation failed.
Diffstat (limited to 'source/blender/imbuf/intern/allocimbuf.c')
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 73d28cd4304..d7ca381bae6 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -201,7 +201,7 @@ bool addzbufImBuf(ImBuf *ibuf)
IMB_freezbufImBuf(ibuf);
- size = (size_t)(ibuf->x * ibuf->y) * sizeof(unsigned int);
+ size = (size_t)ibuf->x * (size_t)ibuf->y * sizeof(unsigned int);
if ((ibuf->zbuf = MEM_mapallocN(size, __func__))) {
ibuf->mall |= IB_zbuf;
@@ -220,7 +220,7 @@ bool addzbuffloatImBuf(ImBuf *ibuf)
IMB_freezbuffloatImBuf(ibuf);
- size = (size_t)(ibuf->x * ibuf->y) * sizeof(float);
+ size = (size_t)ibuf->x * (size_t)ibuf->y * sizeof(float);
if ((ibuf->zbuf_float = MEM_mapallocN(size, __func__))) {
ibuf->mall |= IB_zbuffloat;
@@ -300,7 +300,7 @@ bool imb_addrectfloatImBuf(ImBuf *ibuf)
if (ibuf->rect_float)
imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */
- size = (size_t)(ibuf->x * ibuf->y) * sizeof(float[4]);
+ size = (size_t)ibuf->x * (size_t)ibuf->y * sizeof(float[4]);
ibuf->channels = 4;
if ((ibuf->rect_float = MEM_mapallocN(size, __func__))) {
@@ -324,7 +324,7 @@ bool imb_addrectImBuf(ImBuf *ibuf)
MEM_freeN(ibuf->rect);
ibuf->rect = NULL;
- size = (size_t)(ibuf->x * ibuf->y) * sizeof(unsigned int);
+ size = (size_t)ibuf->x * (size_t)ibuf->y * sizeof(unsigned int);
if ((ibuf->rect = MEM_mapallocN(size, __func__))) {
ibuf->mall |= IB_rect;