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

Schmidt, Lutz lutz.schmidt at sap.com
Wed Sep 26 14:42:06 UTC 2018


Hi Matthias,

your change looks good. Please note that I'm not a reviewer! 

I have a suggestion you might want to think about: 
Why don't you move the free-loop outside the if-else? Except for the NULL check, it's the same code in both branches. 

Thanks for fixing!
Lutz

On 26.09.18, 16:30, "core-libs-dev on behalf of Baesken, Matthias" <core-libs-dev-bounces at openjdk.java.net on behalf of matthias.baesken at sap.com> wrote:

    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