Skip to content

Commit

Permalink
devel/boost-libs: add critical upstream patch (+)
Browse files Browse the repository at this point in the history
Boost.JSON array::erase can segfault, see boostorg/json#692
  • Loading branch information
fluffykhv committed May 23, 2022
1 parent c782899 commit 2d88b73
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions devel/boost-libs/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Created by: Alexander Churanov <churanov.port.maintainer@gmail.com>

PORTNAME= boost-libs
PORTREVISION= 1

COMMENT= Free portable C++ libraries (without Boost.Python)

Expand Down
49 changes: 49 additions & 0 deletions devel/boost-libs/files/patch-0001-json-array-erase-relocate
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();
}
};

0 comments on commit 2d88b73

Please sign in to comment.