-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
devel/boost-libs: add critical upstream patch (+)
Boost.JSON array::erase can segfault, see boostorg/json#692
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
devel/boost-libs/files/patch-0001-json-array-erase-relocate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
diff -ur boost/json/impl/array.ipp boost/json/impl/array.ipp | ||
--- boost/json/impl/array.ipp 2022-04-06 17:02:43.000000000 -0400 | ||
+++ boost/json/impl/array.ipp 2022-04-13 20:55:20.464359478 -0400 | ||
@@ -491,8 +491,11 @@ | ||
auto const p = &(*t_)[0] + | ||
(pos - &(*t_)[0]); | ||
destroy(p, p + 1); | ||
- relocate(p, p + 1, 1); | ||
--t_->size; | ||
+ if(t_->size > 0) | ||
+ relocate(p, p + 1, | ||
+ t_->size - (p - | ||
+ &(*t_)[0])); | ||
return p; | ||
} | ||
|
||
diff -ur libs/json/test/array.cpp libs/json/test/array.cpp | ||
--- libs/json/test/array.cpp 2022-04-06 17:02:43.000000000 -0400 | ||
+++ libs/json/test/array.cpp 2022-04-13 20:53:32.671782680 -0400 | ||
@@ -1270,6 +1270,21 @@ | ||
} | ||
|
||
void | ||
+ testIssue692() | ||
+ { | ||
+ array a; | ||
+ object obj; | ||
+ obj["test1"] = "hello"; | ||
+ a.push_back(obj); | ||
+ a.push_back(obj); | ||
+ a.push_back(obj); | ||
+ a.push_back(obj); | ||
+ a.push_back(obj); | ||
+ while(a.size()) | ||
+ a.erase(a.begin()); | ||
+ } | ||
+ | ||
+ void | ||
run() | ||
{ | ||
testDestroy(); | ||
@@ -1283,6 +1298,7 @@ | ||
testExceptions(); | ||
testEquality(); | ||
testHash(); | ||
+ testIssue692(); | ||
} | ||
}; | ||
|