Skip to content

Commit f15b0ff

Browse files
committed
Add sanity checks
1 parent e21d51d commit f15b0ff

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/transform/BWT.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ bool BWT::forward(SliceArray<byte>& input, SliceArray<byte>& output, int count)
116116
_sa = new int[_saSize];
117117
}
118118

119-
_saAlgo.computeBWT(src, dst, _sa, count, _primaryIndexes, getBWTChunks(count));
119+
if (_saAlgo.computeBWT(src, dst, _sa, count, _primaryIndexes, getBWTChunks(count)) <= 0)
120+
return false;
121+
120122
input._index += count;
121123
output._index += count;
122124
return true;

src/transform/DivSufSort.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ int DivSufSort::computeBWT(const byte input[], byte output[], int bwt[], int len
170170
reset();
171171
const int m = sortTypeBstar(_bucketA, _bucketB, length);
172172
const int pIdx = constructBWT(_bucketA, _bucketB, length, m, indexes, idxCount);
173+
174+
if (pIdx < 0)
175+
return -1;
176+
173177
output[0] = input[length - 1];
174178

175179
for (int i = 0; i < pIdx; i++)

0 commit comments

Comments
 (0)