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/blenkernel/intern/image.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/blenkernel/intern/image.c')
-rw-r--r--source/blender/blenkernel/intern/image.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 41b2b1d80a1..40149c66358 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -682,7 +682,6 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char
if (floatbuf) {
ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat);
- rect_float = ibuf->rect_float;
if (colorspace_settings->name[0] == '\0') {
const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_FLOAT);
@@ -690,11 +689,13 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char
BLI_strncpy(colorspace_settings->name, colorspace, sizeof(colorspace_settings->name));
}
- IMB_colormanagement_check_is_data(ibuf, colorspace_settings->name);
+ if (ibuf != NULL) {
+ rect_float = ibuf->rect_float;
+ IMB_colormanagement_check_is_data(ibuf, colorspace_settings->name);
+ }
}
else {
ibuf = IMB_allocImBuf(width, height, depth, IB_rect);
- rect = (unsigned char *)ibuf->rect;
if (colorspace_settings->name[0] == '\0') {
const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE);
@@ -702,7 +703,14 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char
BLI_strncpy(colorspace_settings->name, colorspace, sizeof(colorspace_settings->name));
}
- IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace_settings->name);
+ if (ibuf != NULL) {
+ rect = (unsigned char *)ibuf->rect;
+ IMB_colormanagement_assign_rect_colorspace(ibuf, colorspace_settings->name);
+ }
+ }
+
+ if (!ibuf) {
+ return NULL;
}
BLI_strncpy(ibuf->name, name, sizeof(ibuf->name));