Skip to content

Commit 4fe0c97

Browse files
authored
Merge pull request #238 from r-spatial/maybe-fix
Attempt to fix sanitizer error
2 parents 7dbf4d2 + ef8c1f8 commit 4fe0c97

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: src/s2/s2region_coverer.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,10 @@ class S2RegionCoverer {
248248
private:
249249
struct Candidate {
250250
void* operator new(std::size_t size, std::size_t max_children) {
251-
return ::operator new (size + max_children * sizeof(Candidate *));
251+
// dd: CRAN reports a sanitizer error when using this magic, so
252+
// we just hard code for the maximum size the comments suggest it will be
253+
// return ::operator new (size + max_children * sizeof(Candidate *));
254+
return ::operator new (size);
252255
}
253256

254257
void operator delete(void* p) {
@@ -268,7 +271,9 @@ class S2RegionCoverer {
268271
S2Cell cell;
269272
bool is_terminal; // Cell should not be expanded further.
270273
int num_children = 0; // Number of children that intersect the region.
271-
__extension__ Candidate* children[0]; // Actual size may be 0, 4, 16, or 64 elements.
274+
// dd: To avoid a sanitizer, we hard-code 64 here rather than rely on
275+
// flexible array member magic.
276+
Candidate* children[64]; // Actual size may be 0, 4, 16, or 64 elements.
272277
};
273278

274279
// If the cell intersects the given region, return a new candidate with no

0 commit comments

Comments
 (0)