Fix a 64-bit pointer truncation bug found by VC++ 2015

When converting from void* to unsigned long long it is dangerous to go
through unsigned long because for VC++ 64-bit builds this will be 32
bits. When casting a pointer to an integral type the safest type to
choose for the integral cast is always intptr_t or uintptr_t.

BUG=440500
NOPRESUBMIT=true

Review URL: https://codereview.webrtc.org/1437433002

Cr-Commit-Position: refs/heads/master@{#10569}
This commit is contained in:
brucedawson 2015-11-09 22:51:52 -08:00 committed by Commit bot
parent e36de90ac1
commit 952892a28a

View File

@ -701,7 +701,7 @@ class TraceID {
explicit TraceID(const void* id, unsigned char* flags)
: data_(static_cast<unsigned long long>(
reinterpret_cast<unsigned long>(id))) {
reinterpret_cast<uintptr_t>(id))) {
*flags |= TRACE_EVENT_FLAG_MANGLE_ID;
}
explicit TraceID(ForceMangle id, unsigned char* flags) : data_(id.data()) {