[OpenJDK 2D-Dev] RFR: JDK-8260432: allocateSpaceForGP in freetypeScaler.c might leak memory [v3]
Thomas Stuefe
stuefe at openjdk.java.net
Thu Jan 28 09:14:43 UTC 2021
On Thu, 28 Jan 2021 08:25:03 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
Hi Matthias,
looks fine. See remark below, but that is just nitpicking, this is fine as it is.
Cheers, Thomas
src/java.desktop/share/native/libfontmanager/freetypeScaler.c line 1297:
> 1295: gpdata->pointCoords = NULL;
> 1296: }
> 1297: return 0;
If you wanted, you could streamline this to:
if (gpdata->pointTypes == NULL || gpdata->pointCoords == NULL) {
free(gpdata->pointTypes);
free(gpdata->pointCoords);
gpdata->pointTypes = gpdata->pointCoords = NULL;
return 0;
Since free(NULL) is valid and a noop.
-------------
Marked as reviewed by stuefe (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/2250
More information about the 2d-dev
mailing list