[cp-patches] FYI: Don't crash in GtkImage when out of memory

Mark Wielaard mark at klomp.org
Wed Jun 14 12:59:42 UTC 2006


Hi,

We would crash and burn in GtkImage when we would run out of memory.
This patch just returns from native code (throwing an
OutOfMemoryException) when we couldn't allocate the int array needed.

2006-06-14  Mark Wielaard  <mark at klomp.org>

    * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
    (Java_gnu_java_awt_peer_gtk_GtkImage_getPixels): Return when array
    cannot be allocated.

Committed,

Mark

--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c        8 Jun
2006 11:09:04 -0000       1.24
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c        14 Jun
2006 12:59:17 -0000
@@ -166,6 +166,11 @@
   rowstride = gdk_pixbuf_get_rowstride (pixbuf);

   result_array = (*env)->NewIntArray (env, (width * height));
+  if (result_array == NULL)
+    {
+      gdk_threads_leave ();
+      return NULL;
+    }

   dst = result_array_iter =
     (*env)->GetIntArrayElements (env, result_array, NULL);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://developer.classpath.org/pipermail/classpath-patches/attachments/20060614/915408cb/attachment.pgp


More information about the Classpath-patches mailing list