Commit 57826cb3 authored by Millian Poquet's avatar Millian Poquet
Browse files

[obfh] json writer: safer memory operations

parent e41ef8c1
......@@ -38,15 +38,16 @@ public:
this->Prefix(rapidjson::kNumberType);
const int buf_size = 32;
char buffer[buf_size];
char * buffer = new char[buf_size];
int ret = snprintf(buffer, sizeof(buffer), "%6f", d);
int ret = snprintf(buffer, buf_size, "%6f", d);
RAPIDJSON_ASSERT(ret >= 1);
const char * end = buffer + ret;
RAPIDJSON_ASSERT(ret < buf_size - 1);
for (char* p = buffer; p != end; ++p)
os_->Put(*p);
for (int i = 0; i < ret; ++i)
os_->Put(buffer[i]);
delete[] buffer;
return ret < (buf_size - 1);
}
......
Supports Markdown
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