[liblouis-liblouisxml] Another crash in Python hyphenation

  • From: Milan Zamazal <pdm@xxxxxxxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Wed, 10 Oct 2012 19:25:15 +0200

I've experienced the following Python crash with liblouis 2.5.1:

  $ python -c 'import louis; louis.hyphenate(["cs-g1.ctb", "hyph_cs_CZ.dic"], 
"xxxxxxxxxxxxxxx")'
  Segmentation fault

This looks similar to the Python hyphenation crash present in 2.4.0.
But this time it happens only in Czech, not in English.  Again, it seems
to happen with strings exactly 15 characters long.

FWIW, the following patch makes the problem disappear:

--- liblouis-2.5.1.orig/python/louis/__init__.py.in     2012-10-10 
13:31:44.000000000 +0200
+++ liblouis-2.5.1/python/louis/__init__.py.in  2012-10-10 13:36:04.281909196 
+0200
@@ -262,7 +262,7 @@
     tablesString = _createTablesString(tableList)
     inbuf = createStr(inbuf)
     inlen = c_int(len(inbuf))
-    hyphen_string = create_string_buffer(inlen.value + 1) 
+    hyphen_string = create_string_buffer(inlen.value + 2) 
     if not liblouis.lou_hyphenate(tablesString, inbuf, inlen, hyphen_string, 
mode):
         raise RuntimeError("Can't hyphenate tables %s, inbuf %s, mode %d" 
%(tablesString, inbuf, mode))
     return hyphen_string.value.decode("ASCII")

For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts: