Checking std::deque size before use it

This commit is contained in:
Felipe Zimmerle 2018-02-06 22:47:24 -03:00
parent 2f86a6b708
commit d0e2382507
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277

View File

@ -127,6 +127,7 @@ int JSON::addArgument(const std::string& value) {
}
}
if (m_containers.size() > 0) {
JSONContainerArray *a = dynamic_cast<JSONContainerArray *>(
m_containers.back());
if (a) {
@ -134,6 +135,10 @@ int JSON::addArgument(const std::string& value) {
} else {
data = getCurrentKey();
}
} else {
data = getCurrentKey();
}
m_transaction->addArgument("JSON", path + data, value, 0);
@ -222,6 +227,10 @@ int JSON::yajl_start_array(void *ctx) {
int JSON::yajl_end_array(void *ctx) {
JSON *tthis = reinterpret_cast<JSON *>(ctx);
if (tthis->m_containers.size() <= 0) {
return 1;
}
JSONContainer *a = tthis->m_containers.back();
tthis->m_containers.pop_back();
delete a;
@ -252,6 +261,10 @@ int JSON::yajl_start_map(void *ctx) {
*/
int JSON::yajl_end_map(void *ctx) {
JSON *tthis = reinterpret_cast<JSON *>(ctx);
if (tthis->m_containers.size() <= 0) {
return 1;
}
JSONContainer *a = tthis->m_containers.back();
tthis->m_containers.pop_back();
delete a;