James Teh <jamie@xxxxxxxxxxxx> writes: > I think this is really a bug in liblouis, though. The documentation > says the output buffer must be of size inlen, so it shouldn't write > past inlen. I looked at the source code of lou_hyphenate and couldn't find the source of the problem. I looked at liblouisxml and the java bindings in liblouisutdml to see how they deal with the issue. liblouisxml just allocates a big static buffer for the hyphens array, so it is probably not directly affected. The java bindings in liblouisutdml might also suffer from the same problem that the Python bindings have. So, if noone is fixing the code in lou_hyphenate I suggest that we put the following workaround in the Python bindings: Index: python/louis/__init__.py.in =================================================================== --- python/louis/__init__.py.in (revision 675) +++ python/louis/__init__.py.in (working copy) @@ -262,7 +262,10 @@ tablesString = _createTablesString(tableList) inbuf = createStr(inbuf) inlen = c_int(len(inbuf)) - hyphen_string = create_string_buffer(inlen.value) + # lou_hyphenate has a bug in that it writes past the end of the + # hyphens array. To work around this we allocate a hyphen_string + # which is slightly bigger than it really ought to be + hyphen_string = create_string_buffer(inlen.value + sizeof(c_wchar)) 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") -- Christian Egli Swiss Library for the Blind, Visually Impaired and Print Disabled Grubenstrasse 12, CH-8045 Zürich, Switzerland ----- Tag der offenen Tuer Die SBS laedt Sie herzlich ein: 30. Juni 2012 von 9 bis 16 Uhr. Mehr Informationen erhalten Sie unter www.sbs.ch/offenetuer For a description of the software, to download it and links to project pages go to http://www.abilitiessoft.com