Commits

Alex Moiseenko committed ae34c3d

DAWG object should not fail if it was asked to load wrong file path
with futher key checking operation

  • Participants
  • Parent commits b050764

Comments (0)

Files changed (1)

File tests/test_dawg.py

                 d.read(f)
                 assert 'Invalid' in e.args[0]
 
+    def test_no_segfaults_after_wrong_stream(self):
+        d = dawg.DAWG()
+        wrong_path = tempfile.mktemp()  # file doesn't exists
+
+        try:
+            d.load(wrong_path)
+        except:
+            pass                     # ignore error
+        assert 'random-key' not in d # there is possible segfault
+
     def test_build_errors(self):
         with pytest.raises(dawg.Error):
             data = [b'foo\x00bar', b'bar']