[liblouis-liblouisxml] Re: Crash in Python hyphenation

  • From: Christian Egli <christian.egli@xxxxxx>
  • To: James Teh <jamie@xxxxxxxxxxxx>
  • Date: Thu, 07 Jun 2012 14:16:08 +0200

James Teh <jamie@xxxxxxxxxxxx> writes:

> On 7/06/2012 7:42 PM, James Teh wrote:
>> 1. The documentation for lou_hyphenate needs to be clarified to indicate
>> that the hyphens string should be of size inlen + 1 (to account for the
>> NULL terminator);
> The Python bindings of course need to be updated accordingly; i.e.
> using inlen.value + 1.

I just commited a fix which changes the documentation and fixes the
Python bindings.

> 267   for (i = 0; i < wordSize; i++)
> 268     hyphens[i] = '0';

I just checked this with Valgrind. If I run the following command (on
revision 675):

$ make check
$ libtool --mode=execute valgrind -v --tool=memcheck --leak-check=full 
--leak-resolution=high --log-file=valgrind.log ./tests/hyphenate

I'll see the following in valgrind.log:

==10625== Invalid write of size 1
==10625==    at 0x4E489B2: hyphenate (lou_translateString.c:268)
==10625==    by 0x4E4D1CD: lou_hyphenate (lou_translateString.c:1995)
==10625==    by 0x401110: check_hyphenation (brl_checks.c:202)
==10625==    by 0x4011D6: main (hyphenate.c:5)
==10625==  Address 0x54130b0 is 0 bytes after a block of size 16 alloc'd
==10625==    at 0x4C2B6CD: malloc (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10625==    by 0x4010EF: check_hyphenation (brl_checks.c:200)
==10625==    by 0x4011D6: main (hyphenate.c:5)

If I apply the change that Jamie suggests then all the tests pass (as
before) and valgrind reports:

==18321== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)


Thanks
Christian

-- 
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

Other related posts: