8230782: Robot.createScreenCapture() fails if “awt.robot.gtk” is set to false
authordmarkov
Mon, 23 Sep 2019 17:18:03 +0100
changeset 58328 fe46ee1d42ee
parent 58327 d07dea54170b
child 58329 483f14c3e0a2
child 58592 fd7e7bb190aa
8230782: Robot.createScreenCapture() fails if “awt.robot.gtk” is set to false Reviewed-by: prr, serb
src/java.desktop/unix/native/libawt_xawt/awt/multiVis.c
--- a/src/java.desktop/unix/native/libawt_xawt/awt/multiVis.c	Mon Sep 23 13:08:20 2019 +0530
+++ b/src/java.desktop/unix/native/libawt_xawt/awt/multiVis.c	Mon Sep 23 17:18:03 2019 +0100
@@ -218,7 +218,11 @@
      XColor *colors ;
 
      ncolors = (unsigned) src_vis->map_entries ;
-     *src_colors = colors = (XColor *)malloc(ncolors * sizeof(XColor) ) ;
+/* JDK modification.
+ * use calloc instead of malloc to initialize allocated memory
+ *   *src_colors = colors = (XColor *)malloc(ncolors * sizeof(XColor) ) ;
+ */
+     *src_colors = colors = (XColor *)calloc(ncolors, sizeof(XColor));
 
      if(src_vis->class != TrueColor && src_vis->class != DirectColor)
      {