Skip to content

Commit 2baad49

Browse files
authored
Merge pull request #804 from yantaozhao/master
allow nullptr when not care the removed array value
2 parents 80bc776 + e32ee47 commit 2baad49

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

include/json/value.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ Json::Value obj_value(Json::objectValue); // {}
562562
/** \brief Remove the indexed array element.
563563
564564
O(n) expensive operations.
565-
Update 'removed' if removed.
565+
Update 'removed' iff removed.
566566
\return true if removed (no exceptions)
567567
*/
568568
bool removeIndex(ArrayIndex index, Value* removed);

src/lib_json/json_value.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,8 @@ bool Value::removeIndex(ArrayIndex index, Value* removed) {
12431243
if (it == value_.map_->end()) {
12441244
return false;
12451245
}
1246-
*removed = it->second;
1246+
if (removed)
1247+
*removed = it->second;
12471248
ArrayIndex oldSize = size();
12481249
// shift left all items left, into the place of the "removed"
12491250
for (ArrayIndex i = index; i < (oldSize - 1); ++i) {

0 commit comments

Comments
 (0)