diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-18 23:58:49 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-18 23:58:49 +0300 |
commit | 6c5f63b476ccd2ede41b94360641541f0aa9af38 (patch) | |
tree | a959e7f5897441d90e9e2fcf0cef4fe079d48e28 /intern/guardedalloc | |
parent | 0f2adc081716da9f6f09608e762056f3143f91d2 (diff) |
Guardedalloc: Add extra logging and checks in MEM_freeN()
We don't like when NULL is send to MEM_freeN(), but there was some
differences between lockfree and guarded allocators:
- Lockfree would have silently crash, in both release and debug modes
- Guarded allocator would have printed error message, abort in debug
but keep working in release build.
This commit makes lockfree allocator behavior to match guarded one.
Diffstat (limited to 'intern/guardedalloc')
-rw-r--r-- | intern/guardedalloc/intern/mallocn.c | 1 | ||||
-rw-r--r-- | intern/guardedalloc/intern/mallocn_guarded_impl.c | 1 | ||||
-rw-r--r-- | intern/guardedalloc/intern/mallocn_lockfree_impl.c | 8 |
3 files changed, 10 insertions, 0 deletions
diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c index a379837c552..1fd85a0c9f5 100644 --- a/intern/guardedalloc/intern/mallocn.c +++ b/intern/guardedalloc/intern/mallocn.c @@ -17,6 +17,7 @@ * * Contributor(s): Brecht Van Lommel * Campbell Barton + * Sergey Sharybin * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c index ecc54882447..9a503422282 100644 --- a/intern/guardedalloc/intern/mallocn_guarded_impl.c +++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c @@ -22,6 +22,7 @@ * * Contributor(s): Brecht Van Lommel * Campbell Barton + * Sergey Sharybin * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.c b/intern/guardedalloc/intern/mallocn_lockfree_impl.c index eaa60202f3c..b5f3d1b15dc 100644 --- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c +++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c @@ -134,6 +134,14 @@ void MEM_lockfree_freeN(void *vmemh) MemHead *memh = MEMHEAD_FROM_PTR(vmemh); size_t len = MEM_lockfree_allocN_len(vmemh); + if (vmemh == NULL) { + print_error("Attempt to free NULL pointer\n"); +#ifdef WITH_ASSERT_ABORT + abort(); +#endif + return; + } + atomic_sub_u(&totblock, 1); atomic_sub_z(&mem_in_use, len); |