Commit a1a4a1cf authored by danno@chromium.org's avatar danno@chromium.org

Use safe string utilities to fix Windows build error.

R=mstarzinger@chromium.org
TEST=waterfall goes green

Review URL: https://chromiumcodereview.appspot.com/10173023

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11434 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 39fa51d4
...@@ -1553,8 +1553,10 @@ void HGlobalValueNumberer::ComputeBlockSideEffects() { ...@@ -1553,8 +1553,10 @@ void HGlobalValueNumberer::ComputeBlockSideEffects() {
SmartArrayPointer<char> GetGVNFlagsString(GVNFlagSet flags) { SmartArrayPointer<char> GetGVNFlagsString(GVNFlagSet flags) {
char underlying_buffer[kLastFlag * 128];
Vector<char> buffer(underlying_buffer, sizeof(underlying_buffer));
#if DEBUG #if DEBUG
char buffer[kLastFlag * 128]; int offset = 0;
const char* separator = ""; const char* separator = "";
const char* comma = ", "; const char* comma = ", ";
buffer[0] = 0; buffer[0] = 0;
...@@ -1573,17 +1575,17 @@ SmartArrayPointer<char> GetGVNFlagsString(GVNFlagSet flags) { ...@@ -1573,17 +1575,17 @@ SmartArrayPointer<char> GetGVNFlagsString(GVNFlagSet flags) {
bool positive_depends_on = set_depends_on < (kLastFlag / 2); bool positive_depends_on = set_depends_on < (kLastFlag / 2);
if (set_changes > 0) { if (set_changes > 0) {
if (positive_changes) { if (positive_changes) {
strcat(buffer, "changes ["); offset += OS::SNPrintF(buffer + offset, "changes [");
} else { } else {
strcat(buffer, "changes all except ["); offset += OS::SNPrintF(buffer + offset, "changes all except [");
} }
for (int bit = 0; bit < kLastFlag; ++bit) { for (int bit = 0; bit < kLastFlag; ++bit) {
if (((flags.ToIntegral() & (1 << bit)) != 0) == positive_changes) { if (((flags.ToIntegral() & (1 << bit)) != 0) == positive_changes) {
switch (static_cast<GVNFlag>(bit)) { switch (static_cast<GVNFlag>(bit)) {
#define DECLARE_FLAG(type) \ #define DECLARE_FLAG(type) \
case kChanges##type: \ case kChanges##type: \
strcat(buffer, separator); \ offset += OS::SNPrintF(buffer + offset, separator); \
strcat(buffer, #type); \ offset += OS::SNPrintF(buffer + offset, #type); \
separator = comma; \ separator = comma; \
break; break;
GVN_TRACKED_FLAG_LIST(DECLARE_FLAG) GVN_TRACKED_FLAG_LIST(DECLARE_FLAG)
...@@ -1594,25 +1596,25 @@ GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) ...@@ -1594,25 +1596,25 @@ GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG)
} }
} }
} }
strcat(buffer, "]"); offset += OS::SNPrintF(buffer + offset, "]");
} }
if (set_depends_on > 0) { if (set_depends_on > 0) {
separator = ""; separator = "";
if (set_changes > 0) { if (set_changes > 0) {
strcat(buffer, ", "); offset += OS::SNPrintF(buffer + offset, ", ");
} }
if (positive_depends_on) { if (positive_depends_on) {
strcat(buffer, "depends on ["); offset += OS::SNPrintF(buffer + offset, "depends on [");
} else { } else {
strcat(buffer, "depends on all except ["); offset += OS::SNPrintF(buffer + offset, "depends on all except [");
} }
for (int bit = 0; bit < kLastFlag; ++bit) { for (int bit = 0; bit < kLastFlag; ++bit) {
if (((flags.ToIntegral() & (1 << bit)) != 0) == positive_depends_on) { if (((flags.ToIntegral() & (1 << bit)) != 0) == positive_depends_on) {
switch (static_cast<GVNFlag>(bit)) { switch (static_cast<GVNFlag>(bit)) {
#define DECLARE_FLAG(type) \ #define DECLARE_FLAG(type) \
case kDependsOn##type: \ case kDependsOn##type: \
strcat(buffer, separator); \ offset += OS::SNPrintF(buffer + offset, separator); \
strcat(buffer, #type); \ offset += OS::SNPrintF(buffer + offset, #type); \
separator = comma; \ separator = comma; \
break; break;
GVN_TRACKED_FLAG_LIST(DECLARE_FLAG) GVN_TRACKED_FLAG_LIST(DECLARE_FLAG)
...@@ -1623,14 +1625,15 @@ GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) ...@@ -1623,14 +1625,15 @@ GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG)
} }
} }
} }
strcat(buffer, "]"); offset += OS::SNPrintF(buffer + offset, "]");
} }
#else #else
char buffer[128]; OS::SNPrintF(buffer, "0x%08X", flags.ToIntegral());
snprintf(buffer, 128, "0x%08X", flags.ToIntegral());
#endif #endif
char* result = new char[strlen(buffer) + 1]; uint32_t string_len = strlen(underlying_buffer) + 1;
strcpy(result, buffer); ASSERT(string_len <= sizeof(underlying_buffer));
char* result = new char[strlen(underlying_buffer) + 1];
memcpy(result, underlying_buffer, string_len);
return SmartArrayPointer<char>(result); return SmartArrayPointer<char>(result);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment