Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#21 Heap corruption for UTF8

closed
None
5
2007-06-14
2007-04-03
idb_winshell
No

Hi,

one might trap in heap corruption when running multiple instances of Hunspell with the global variable 'utf_tbl' in csutil.cxx.

To avoid this, change

int initialize_utf_tbl() {
utf_tbl = (unicode_info2 *) malloc(CONTSIZE * sizeof(unicode_info2));
...

to

int initialize_utf_tbl() {
free_utf_tbl(); // <-- new
utf_tbl = (unicode_info2 *) malloc(CONTSIZE * sizeof(unicode_info2));
...

and also

void free_utf_tbl() {
if (utf_tbl) free(utf_tbl);
}

to

void free_utf_tbl() {
if (utf_tbl){
free(utf_tbl);
utf_tbl = NULL; // <-- new
}
}

greets
Ingo

Discussion

  • idb_winshell
    idb_winshell
    2007-04-03

    Logged In: YES
    user_id=1397672
    Originator: YES

    Hi,

    you might also take a look at functions using utf_tbl, like unicodetoupper, unicodetolower and unicodeisalpha. utf_tbl is not tested on NULL.

    greets
    Ingo

     
  • Logged In: YES
    user_id=726595
    Originator: NO

    In version 1.4, there were different UTF-8 tables for the different instances, but now embegged Hunspell uses UTF-8 conversion functions of OpenOffice.org and Mozilla. Unfortunatelly, this optimization has'nt been perfect yet, but I will fix it in the next version (I also plan to use iconv conversion functions on Linux here.) Many thanks for the bug report. Laci

     
    • assigned_to: nobody --> nemethl
     
    • status: open --> closed
     
  • Logged In: YES
    user_id=726595
    Originator: NO

    Fixed. I have added a counter for the multiple instances. Thanks, Laci