File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,17 @@ print_next <- function() {
81
81
)
82
82
cli :: cat_bullet(
83
83
" Fix zero-length array warnings under -Wpedantic by inserting __extension__ at the beginning " ,
84
- " of expressions declaring them (s2region_coverer.h#251, util/gtl/compact_array.h#124 )"
84
+ " of expressions declaring them (s2region_coverer.h#271 )"
85
85
)
86
+ cli :: cat_bullet(
87
+ " Fix compact_array zero-length array warning by disabling inline elements on gcc " ,
88
+ " (util/gtl/compact_array.h#89)"
89
+ )
90
+ cli :: cat_bullet(
91
+ " Fix sanitizer error for compact_array when increasing the size of a zero-length array " ,
92
+ " by wrapping util/gtl/compact_array.h#396-397 with if (old_capacity > 0) {...}"
93
+ )
94
+
86
95
cli :: cat_bullet(" Remove extra semi-colon at s2boolean_operation.h#376" )
87
96
cli :: cat_bullet(" Remove extra semi-colons because of FROMHOST_TYPE_MAP macro (utils/endian/endian.h#565)" )
88
97
cli :: cat_bullet(
Original file line number Diff line number Diff line change @@ -86,6 +86,9 @@ class compact_array_base {
86
86
#endif
87
87
88
88
// Opportunistically consider allowing inlined elements.
89
+ // dd: this has to be disabled to pass CRAN checks, since there is a
90
+ // (potentially) zero-length array that is not the last element of the class (so
91
+ // this can't be silenced using __extension__)
89
92
#if defined(_LP64) && defined(__GNUC__) && false
90
93
// With 64-bit pointers, our approach is to form a 16-byte struct:
91
94
// [5 bytes for size, capacity, is_exponent and is_inlined]
@@ -393,6 +396,9 @@ class compact_array_base {
393
396
value_allocator_type allocator;
394
397
395
398
T* new_ptr = allocator.allocate (capacity ());
399
+ // dd: this modification fixes a ASAN/UBSAN error, because
400
+ // when old_capacity is 0, Array() is nullptr, which is UB
401
+ // for memcpy.
396
402
if (old_capacity > 0 ) {
397
403
memcpy (new_ptr, Array (), old_capacity * sizeof (T));
398
404
allocator.deallocate (Array (), old_capacity);
You can’t perform that action at this time.
0 commit comments