[XS] RFR : 8211149: fix potential memleak in getJavaIDFromLangID after failing SetupI18nProps call [windows]

Baesken, Matthias matthias.baesken at sap.com
Wed Sep 26 14:29:09 UTC 2018


Hello,   could you please review this small change   (windows only)   ?

Currently, the function   "getJavaIDFromLangID"    (located in windows java_props_md.c)
only does proper deallocations after a  successful call to the  function SetupI18nProps.  See

    if (SetupI18nProps(MAKELCID(langID, SORT_DEFAULT),
                   &(elems[0]), &(elems[1]), &(elems[2]), &(elems[3]), &(elems[4]))) {

   ......
        for (index = 0; index < 5; index++) {
            free(elems[index]);
        }


However a failing call (SetupI18nProps returning false) might still need deallocations,  because the function  SetupI18nProps can malloc memory in the failing case as well .
The change initializes   the   pointers  in  char * elems[5];
And later  frees them in case they are not NULL .

Webrev and bug :

http://cr.openjdk.java.net/~mbaesken/webrevs/8211149.0/8211149.0/webrev/

https://bugs.openjdk.java.net/browse/JDK-8211149


Best regards, Matthias


More information about the core-libs-dev mailing list