Skip to content

Commit

Permalink
[bug] Fix SC-17415: segfault due to underflow in for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ihnorton committed May 5, 2022
1 parent 762f975 commit 895d5e7
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions tiledb/sm/misc/comparators.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class GlobalCmp : protected CellCmpBase {
}
} else { // COL_MAJOR
assert(tile_order_ == Layout::COL_MAJOR);
for (unsigned d = dim_num_ - 1;; --d) {
for (int32_t d = static_cast<int32_t>(dim_num_) - 1; d >= 0; d--) {
// Not applicable to var-sized dimensions
if (domain_.dimension_ptr(d)->var_size())
continue;
Expand All @@ -312,9 +312,6 @@ class GlobalCmp : protected CellCmpBase {
if (res == 1)
return false;
// else same tile on dimension d --> continue

if (d == 0)
break;
}
}

Expand All @@ -331,17 +328,14 @@ class GlobalCmp : protected CellCmpBase {
}
} else { // COL_MAJOR
assert(cell_order_ == Layout::COL_MAJOR);
for (unsigned d = dim_num_ - 1;; --d) {
for (int32_t d = static_cast<int32_t>(dim_num_) - 1; d >= 0; d--) {
auto res = cell_order_cmp_RC(d, a, b);

if (res == -1)
return true;
if (res == 1)
return false;
// else same tile on dimension d --> continue

if (d == 0)
break;
}
}

Expand Down

0 comments on commit 895d5e7

Please sign in to comment.