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>2019-02-21 12:52:03 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-02-21 12:52:03 +0300
commit7412f30930945de03fa621cf3c2b5bfdfc46311b (patch)
tree9b6193224aaf6c3198d64226e4499d39452b0cc8 /source/blender/editors/space_clip/clip_editor.c
parentf4d9e49f286fc50470fff51f04a1cf70b63b799f (diff)
Clip: Check memory allocation during prefetch
Aimed to make prefetching more stable for cases when it causes Blender to run out of memory.
Diffstat (limited to 'source/blender/editors/space_clip/clip_editor.c')
-rw-r--r--source/blender/editors/space_clip/clip_editor.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 5e161300dcc..f6959dd593c 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -640,29 +640,29 @@ static unsigned char *prefetch_read_file_to_memory(
size_t *r_size)
{
MovieClipUser user = {0};
- char name[FILE_MAX];
- size_t size;
- int file;
- unsigned char *mem;
-
user.framenr = current_frame;
user.render_size = render_size;
user.render_flag = render_flag;
+ char name[FILE_MAX];
BKE_movieclip_filename_for_frame(clip, &user, name);
- file = BLI_open(name, O_BINARY | O_RDONLY, 0);
+ int file = BLI_open(name, O_BINARY | O_RDONLY, 0);
if (file == -1) {
return NULL;
}
- size = BLI_file_descriptor_size(file);
+ const size_t size = BLI_file_descriptor_size(file);
if (size < 1) {
close(file);
return NULL;
}
- mem = MEM_mallocN(size, "movieclip prefetch memory file");
+ unsigned char *mem = MEM_mallocN(size, "movieclip prefetch memory file");
+ if (mem == NULL) {
+ close(file);
+ return NULL;
+ }
if (read(file, mem, size) != size) {
close(file);