Skip to content

Commit

Permalink
Allow empty SA-IS input.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Feb 22, 2019
1 parent f67bc65 commit 640576a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 1 addition & 7 deletions detools/sais.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,13 +815,7 @@ static PyObject* sais_wrapper(PyObject* self_p, PyObject* arg_p)
return (NULL);
}

if (size == 0) {
PyErr_SetString(PyExc_ValueError, "SA-IS data empty.");

return (NULL);
}

suffix_array_p = PyMem_Malloc(size * sizeof(int));
suffix_array_p = PyMem_Malloc((size + 1) * sizeof(int));

if (suffix_array_p == NULL) {
return (NULL);
Expand Down
8 changes: 8 additions & 0 deletions tests/test_sais.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ class DetoolsSaisTest(unittest.TestCase):

def test_sais(self):
datas = [
(
b'',
[0]
),
(
b'1',
[1, 0]
),
(
b'1234',
[4, 0, 1, 2, 3]
Expand Down

0 comments on commit 640576a

Please sign in to comment.