diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2018-11-07 10:15:31 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2018-11-07 10:40:40 +0300 |
commit | c1976a3967b467d09589d306712abef0958048b3 (patch) | |
tree | 526f90067c69b42d9b05536287a51231358a1947 /extra | |
parent | d8155cfed46d8d571f1c9f5e1d561cda87192bb0 (diff) | |
download | bdwgc-c1976a3967b467d09589d306712abef0958048b3.tar.gz |
Workaround 'pointer addition with NULL pointer' cppcheck error in msvc_dbg
* extra/msvc_dbg.c (GetDescriptionFromStack): Change type of begin,
end, buffer local variables from char* to GC_ULONG_PTR; do not update
size local variable value; do not store elements to description[]
if description is NULL (instead of checking of size is non-zero).
Diffstat (limited to 'extra')
-rw-r--r-- | extra/msvc_dbg.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/extra/msvc_dbg.c b/extra/msvc_dbg.c index b7ef8d9c..858c67ea 100644 --- a/extra/msvc_dbg.c +++ b/extra/msvc_dbg.c @@ -352,18 +352,18 @@ size_t GetDescriptionFromStack(void* const frames[], size_t count, const char* format, char* description[], size_t size) { - char*const begin = (char*)description; - char*const end = begin + size; - char* buffer = begin + (count + 1) * sizeof(char*); + const GC_ULONG_PTR begin = (GC_ULONG_PTR)description; + const GC_ULONG_PTR end = begin + size; + GC_ULONG_PTR buffer = begin + (count + 1) * sizeof(char*); size_t i; (void)format; for (i = 0; i < count; ++i) { - 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[i] = (char*)buffer; + buffer += 1 + GetDescriptionFromAddress(frames[i], NULL, (char*)buffer, + end < buffer ? 0 : end - buffer); } - if (size) + if (description) description[count] = NULL; return buffer - begin; } |