diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2018-04-06 00:42:29 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2018-04-06 00:42:29 +0300 |
commit | dbb34733c7d9f985bc779ece40100eb882ccec7e (patch) | |
tree | 8d0e8b37eae06b3ac7f014967cccf54888c8544e /extra | |
parent | 295a2f24e2ebb39afcbc5763fecd09daa2982390 (diff) | |
download | bdwgc-dbb34733c7d9f985bc779ece40100eb882ccec7e.tar.gz |
Eliminate 'there is pointer arithmetic with NULL' cppcheck warning
* extra/msvc_dbg.c (GetDescriptionFromStack): Compare size to 0 instead
of comparing description to NULL; mark format argument as used.
* extra/msvc_dbg.c (backtrace_symbols): Do not call
GetDescriptionFromStack if symbols (description) is NULL but size is
non-zero.
Diffstat (limited to 'extra')
-rw-r--r-- | extra/msvc_dbg.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/extra/msvc_dbg.c b/extra/msvc_dbg.c index 42aceeb2..8abe2473 100644 --- a/extra/msvc_dbg.c +++ b/extra/msvc_dbg.c @@ -353,12 +353,15 @@ size_t GetDescriptionFromStack(void* const frames[], size_t count, char*const end = begin + size; char* buffer = begin + (count + 1) * sizeof(char*); size_t i; + (void)format; for (i = 0; i < count; ++i) { - if (description) description[i] = buffer; + if (size) + description[i] = buffer; size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer; buffer += 1 + GetDescriptionFromAddress(frames[i], NULL, buffer, size); } - if (description) description[count] = NULL; + if (size) + description[count] = NULL; return buffer - begin; } @@ -373,7 +376,8 @@ char** backtrace_symbols(void*const* addresses, int count) { size_t size = GetDescriptionFromStack(addresses, count, NULL, NULL, 0); char** symbols = (char**)malloc(size); - GetDescriptionFromStack(addresses, count, NULL, symbols, size); + if (symbols != NULL) + GetDescriptionFromStack(addresses, count, NULL, symbols, size); return symbols; } |