summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-11-07 10:15:31 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-11-07 10:40:40 +0300
commitc1976a3967b467d09589d306712abef0958048b3 (patch)
tree526f90067c69b42d9b05536287a51231358a1947 /extra
parentd8155cfed46d8d571f1c9f5e1d561cda87192bb0 (diff)
downloadbdwgc-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.c16
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;
}