<AWT Dev> <AWT dev>[9] Review request for 8156121: "Fail forward" fails for GTK3 if no GTK2 available

Phil Race philip.race at oracle.com
Fri May 27 16:30:42 UTC 2016


  67         n_libs = sizeof(gtk_libs) / sizeof(GtkLib);
   68         load_order = malloc(1 + n_libs * sizeof(GtkLib *));
   69         load_order[n_libs] = 0;

I think you meant

  malloc((1 + n_libs) * sizeof(GtkLib *));

since otherwise you are only allocating one byte for the pointer
and will have a buffer overrun.

But it would be better to use calloc :-


calloc(n_libs+1,sizeof(GtkLib *));

and then you can dispense with line 69 since calloc zero initialises memory.

-phil.


On 05/26/2016 05:33 AM, Semyon Sadetsky wrote:
> Hello,
>
> Please review fix for JDK9:
>
> bug: https://bugs.openjdk.java.net/browse/JDK-8156121
>
> webrev: http://cr.openjdk.java.net/~ssadetsky/8156121/webrev.00/
>
> The issue is caused by changes in -Djdk.gtk.version=<gtk version> 
> specification. Initially it should be working as a constraint:  only 
> allow the specified version of GTK lib (don't use GTK if this version 
> is not available). Then after discussions the specification was 
> amended to use this property as a advise: the GTK version to start 
> loading with (if it fails the next available GTK version will be 
> attempted). So that, the code need be harmonized with the specification.
>
> --Semyon
>



More information about the awt-dev mailing list