Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index 409b597f7454511e3dc2c28c1863b9cec527d27f..6965cb5632538ed95c0dbee6c4ec98feee175971 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -6627,9 +6627,10 @@ const char* PcDescriptors::ToCString() const { |
if (Length() == 0) { |
return "No pc descriptors\n"; |
} |
- const char* kFormat = "0x%x\t%s\t%ld\t%ld\t%ld\n"; |
+ const char* kFormat = |
+ "0x%" PRIxPTR "\t%s\t%" PRIdPTR "\t%" PRIdPTR "\t%" PRIdPTR "\n"; |
// First compute the buffer size required. |
- intptr_t len = 0; |
+ intptr_t len = 1; // Trailing '\0'. |
for (intptr_t i = 0; i < Length(); i++) { |
const intptr_t multi_purpose_index = DescriptorKind(i) == kDeoptIndex ? |
DeoptIndex(i) : TryIndex(i); |
@@ -6638,7 +6639,7 @@ const char* PcDescriptors::ToCString() const { |
} |
// Allocate the buffer. |
char* buffer = reinterpret_cast<char*>( |
- Isolate::Current()->current_zone()->Allocate(len + 1)); |
+ Isolate::Current()->current_zone()->Allocate(len)); |
// Layout the fields in the buffer. |
intptr_t index = 0; |
for (intptr_t i = 0; i < Length(); i++) { |
@@ -6900,20 +6901,20 @@ const char* ExceptionHandlers::ToCString() const { |
return "No exception handlers\n"; |
} |
// First compute the buffer size required. |
- intptr_t len = 0; |
+ const char* kFormat = "%" PRIdPTR " => 0x%" PRIxPTR "\n"; |
+ intptr_t len = 1; // Trailing '\0'. |
for (intptr_t i = 0; i < Length(); i++) { |
- len += OS::SNPrint(NULL, 0, "%ld => 0x%x\n", |
- TryIndex(i), HandlerPC(i)); |
+ len += OS::SNPrint(NULL, 0, kFormat, TryIndex(i), HandlerPC(i)); |
} |
// Allocate the buffer. |
char* buffer = reinterpret_cast<char*>( |
- Isolate::Current()->current_zone()->Allocate(len + 1)); |
+ Isolate::Current()->current_zone()->Allocate(len)); |
// Layout the fields in the buffer. |
intptr_t index = 0; |
for (intptr_t i = 0; i < Length(); i++) { |
index += OS::SNPrint((buffer + index), |
(len - index), |
- "%ld => 0x%x\n", |
+ kFormat, |
TryIndex(i), |
HandlerPC(i)); |
} |