diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-08-04 08:30:14 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-08-04 08:30:14 +0400 |
commit | a270481239f7f8befc5b68056c56f5e2363e4027 (patch) | |
tree | 40c684d334477147edc3c88961596afd8cac6f83 /intern/rigidbody | |
parent | fee152d0ec4284982d80177dd0a6eb3fc9e9a6f0 (diff) |
add missing NULL check in RB_dworld_export if fopen fails.
Diffstat (limited to 'intern/rigidbody')
-rw-r--r-- | intern/rigidbody/rb_bullet_api.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp index 58e355c0d52..5724d1992d9 100644 --- a/intern/rigidbody/rb_bullet_api.cpp +++ b/intern/rigidbody/rb_bullet_api.cpp @@ -57,6 +57,7 @@ subject to the following restrictions: */ #include <stdio.h> +#include <errno.h> #include "RBI_api.h" @@ -218,8 +219,13 @@ void RB_dworld_export(rbDynamicsWorld *world, const char *filename) world->dynamicsWorld->serialize(serializer); FILE *file = fopen(filename, "wb"); - fwrite(serializer->getBufferPointer(), serializer->getCurrentBufferSize(), 1, file); - fclose(file); + if (file) { + fwrite(serializer->getBufferPointer(), serializer->getCurrentBufferSize(), 1, file); + fclose(file); + } + else { + fprintf(stderr, "RB_dworld_export: %s\n", strerror(errno)); + } } /* ********************************** */ |