diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2017-08-09 11:10:38 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2017-08-09 11:26:14 +0300 |
commit | c4f8f000273f029e9aebc8eb305a21975c853786 (patch) | |
tree | f808bf98b7fe334fabeaf01dfbfc054d80a84875 /mallocx.c | |
parent | 348bc2ba8d5556f4e655675b94e1b29e80b40fdc (diff) | |
download | bdwgc-c4f8f000273f029e9aebc8eb305a21975c853786.tar.gz |
Do not call BCOPY and BZERO if size is zero
* dbg_mlc.c (GC_debug_strndup): Do not call BCOPY() if elements count
is zero.
* dbg_mlc.c (GC_debug_realloc): Likewise.
* finalize.c [!GC_TOGGLE_REFS_NOT_NEEDED] (ensure_toggleref_capacity):
Likewise.
* malloc.c [REDIRECT_MALLOC && !strndup] (strndup): Likewise.
* mallocx.c (GC_strndup): Likewise.
* misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (GC_get_prof_stats): Likewise.
* os_dep.c [SAVE_CALL_CHAIN && GC_HAVE_BUILTIN_BACKTRACE]
(GC_save_callers): Likewise.
* reclaim.c (GC_print_all_errors): Likewise.
* malloc.c (GC_free): Do not call BZERO() if elements count is zero.
* malloc.c [THREADS] (GC_free_inner): Likewise.
* reclaim.c (GC_print_all_errors): Likewise.
* misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED && THREADS]
(GC_get_prof_stats_unsafe): Do not call fill_prof_stats() and BCOPY()
if stats_sz is zero.
Diffstat (limited to 'mallocx.c')
-rw-r--r-- | mallocx.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -542,7 +542,8 @@ GC_API GC_ATTR_MALLOC char * GC_CALL GC_strndup(const char *str, size_t size) # endif return NULL; } - BCOPY(str, copy, len); + if (EXPECT(len > 0, TRUE)) + BCOPY(str, copy, len); copy[len] = '\0'; return copy; } |