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() {
8181 )
8282 cli :: cat_bullet(
8383 " 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 )"
8585 )
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+
8695 cli :: cat_bullet(" Remove extra semi-colon at s2boolean_operation.h#376" )
8796 cli :: cat_bullet(" Remove extra semi-colons because of FROMHOST_TYPE_MAP macro (utils/endian/endian.h#565)" )
8897 cli :: cat_bullet(
Original file line number Diff line number Diff line change @@ -86,6 +86,9 @@ class compact_array_base {
8686#endif
8787
8888 // 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__)
8992#if defined(_LP64) && defined(__GNUC__) && false
9093 // With 64-bit pointers, our approach is to form a 16-byte struct:
9194 // [5 bytes for size, capacity, is_exponent and is_inlined]
@@ -393,6 +396,9 @@ class compact_array_base {
393396 value_allocator_type allocator;
394397
395398 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.
396402 if (old_capacity > 0 ) {
397403 memcpy (new_ptr, Array (), old_capacity * sizeof (T));
398404 allocator.deallocate (Array (), old_capacity);
You can’t perform that action at this time.
0 commit comments