[OpenJDK 2D-Dev] RFR: 8230480: check malloc/calloc results in java.desktop

Baesken, Matthias matthias.baesken at sap.com
Wed Sep 4 08:56:52 UTC 2019

Hi Phil ,   I think you are  right,  the "depth > 12"  is a legitimate  case  so no freeing should be done there .

New webrev :

  *   Removed the free for "depth > 12"
  *   ZALLOC-ed    "awt_data->color_data = ZALLOC (_ColorData);"   in X11Color.c  needs return value handling too


Best regards, Matthias

From: Phil Race <philip.race at oracle.com>
Sent: Dienstag, 3. September 2019 18:58
To: Baesken, Matthias <matthias.baesken at sap.com>; awt-dev at openjdk.java.net; 2d-dev at openjdk.java.net
Subject: Re: [OpenJDK 2D-Dev] RFR: 8230480: check malloc/calloc results in java.desktop

I am not sure about that free you added.
A return of "1" means success. And a caller is then expecting the awtImage to be valid.

How did you determine that this was the correct thing to do here ?

On 9/3/19 8:40 AM, Baesken, Matthias wrote:
Hello,  please review this small change .

I noticed that  at a few places  in java.desktop  checking  malloc/calloc   return  values  is not done.
This should be changed .

Additionally  I  think we miss here a free in an early return, changed it too :


567     if (depth > 12) {
568         free (awt_data->awtImage);
569         return 1;
570     }

Build/webrev :



Thanks, Matthias

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/2d-dev/attachments/20190904/b509833b/attachment.html>

More information about the 2d-dev mailing list