if data is removed through bundle_foreach(),
A crash may occur.
This patch resolves this by passing the iterator to the next before calling the callback using the iterator.
Change-Id: I3f04418f47bc17247e857362b462e616c2136fa0
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
}
auto* h = reinterpret_cast<Bundle*>(b);
- for (const auto& kv : h->GetMap()) {
- auto& key_info = kv.second;
+ auto it = h->GetMap().begin();
+ while (it != h->GetMap().end()) {
+ auto& key_info = it->second;
+ ++it;
callback(key_info->GetKey().c_str(), key_info->GetType(),
- reinterpret_cast<bundle_keyval_t*>(key_info.get()), user_data);
+ reinterpret_cast<bundle_keyval_t*>(key_info.get()), user_data);
}
set_last_result(BUNDLE_ERROR_NONE);