--- old/src/solaris/native/sun/java2d/x11/XRBackendNative.c	2011-03-28 17:14:40.462240002 +0200
+++ new/src/solaris/native/sun/java2d/x11/XRBackendNative.c	2011-03-28 17:14:40.215240001 +0200
@@ -640,7 +640,7 @@
         free(gid);
         return;
     }
-
+  
     for (i=0; i < glyphCnt; i++) {
       GlyphInfo *jginfo = (GlyphInfo *) jlong_to_ptr(glyphInfoPtrs[i]);
 
@@ -666,16 +666,27 @@
 JNIEXPORT void JNICALL
 Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative
  (JNIEnv *env, jclass cls, jint glyphSet, jintArray gidArray, jint glyphCnt) {
-    jint *gids;
+    jint *ids;
+    Glyph *gids;
     int i;
+    
+    if((gids = (Glyph *) malloc(sizeof(Glyph) * glyphCnt)) == NULL) {
+      return;
+    }
+    
+    if ((ids = (jint *) (*env)->GetPrimitiveArrayCritical(env, gidArray, NULL)) == NULL) {
+      free(gids);
+      return;
+    }
 
-    if ((gids = (jint *) (*env)->GetPrimitiveArrayCritical(env, gidArray, NULL)) == NULL) {
-        return;
+    for (i=0; i < glyphCnt; i++) {
+      gids[i] = ids[i];
     }
 
-    XRenderFreeGlyphs (awt_display, (GlyphSet) glyphSet, (Glyph *) gids, glyphCnt);
+    XRenderFreeGlyphs (awt_display, (GlyphSet) glyphSet, gids, glyphCnt);
 
     (*env)->ReleasePrimitiveArrayCritical(env, gidArray, gids, JNI_ABORT);
+    free(gids);
 }
 
 JNIEXPORT jint JNICALL
@@ -692,9 +703,9 @@
     jint *ids;
     jint *elts;
     XGlyphElt32 *xelts;
-    Glyph *xids;
+    unsigned int *xids;
     XGlyphElt32 selts[24];
-    Glyph sids[256];
+    unsigned int sids[256];
     int charCnt = 0;
 
     if (eltCnt <= 24) {
@@ -709,7 +720,7 @@
     if (glyphCnt <= 256) {
       xids = &sids[0];
     } else {
-      xids = (Glyph *) malloc(sizeof(Glyph) * glyphCnt);
+      xids = (Glyph *) malloc(sizeof(unsigned int) * glyphCnt);
       if (xids == NULL) {
           if (xelts != &selts[0]) {
             free(xelts);
@@ -740,9 +751,9 @@
         }
         return;
     }
-
+    
     for (i=0; i < glyphCnt; i++) {
-      xids[i] = (Glyph) ids[i];
+      xids[i] = ids[i];
     }
 
     for (i=0; i < eltCnt; i++) {
@@ -750,7 +761,7 @@
       xelts[i].xOff = elts[i*4 + 1];
       xelts[i].yOff = elts[i*4 + 2];
       xelts[i].glyphset = (GlyphSet) elts[i*4 + 3];
-      xelts[i].chars = (unsigned int *) &xids[charCnt];
+      xelts[i].chars = &xids[charCnt];
 
       charCnt += xelts[i].nchars;
     }
@@ -758,7 +769,7 @@
     XRenderCompositeText32(awt_display, op, (Picture) src, (Picture) dst,
                            (XRenderPictFormat *) jlong_to_ptr(maskFmt),
                             0, 0, 0, 0, xelts, eltCnt);
-
+    
     (*env)->ReleasePrimitiveArrayCritical(env, glyphIDArray, ids, JNI_ABORT);
     (*env)->ReleasePrimitiveArrayCritical(env, eltArray, elts, JNI_ABORT);
 
