[OpenJDK 2D-Dev] RFR: JDK-8260432: allocateSpaceForGP in freetypeScaler.c might leak memory [v2]

Aleksey Shipilev shade at openjdk.java.net
Thu Jan 28 07:56:43 UTC 2021


On Wed, 27 Jan 2021 13:09:56 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

>> The function  AllocateSpaceForGP in freetypeScaler.c calls potentially 2 times malloc ; however the memory is not always freed correctly in case of errors.
>> See also the related  sonar issue :
>> https://sonarcloud.io/project/issues?id=shipilev_jdk&languages=c&open=AXck8B_SBBG2CXpcngxr&resolved=false&severities=BLOCKER&types=BUG
>
> Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
> 
>   JDK-8260426

This looks fine to me, modulo stylistic nits

src/java.desktop/share/native/libfontmanager/freetypeScaler.c line 1289:

> 1287:     /* failure if any of mallocs failed */
> 1288:     if (gpdata->pointTypes == NULL || gpdata->pointCoords == NULL) {
> 1289:         if (gpdata->pointTypes != NULL)  { free(gpdata->pointTypes); gpdata->pointTypes = NULL; }

You might want to add an extra space before `gpdata->pointTypes = NULL;` to align the statements vertically. You call.

-------------

Marked as reviewed by shade (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/2250


More information about the 2d-dev mailing list