OSDN Git Service

don't pass NULL buffer or 0 capacity to env->NewDirectByteBuffer() as CheckJNI and...
authorAmir Szekely <kichik@gmail.com>
Sun, 16 Sep 2012 23:40:16 +0000 (16:40 -0700)
committerAmir Szekely <kichik@gmail.com>
Sun, 16 Sep 2012 23:40:16 +0000 (16:40 -0700)
extensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreeType.java

index b194a56..c7cc7cf 100644 (file)
@@ -348,6 +348,13 @@ public class FreeType {
                */\r
                \r
                public ByteBuffer getBuffer() {\r
+                       if (getRows() == 0)\r
+                               // Issue #768 - CheckJNI frowns upon env->NewDirectByteBuffer with NULL buffer or capacity 0\r
+                               //                  "JNI WARNING: invalid values for address (0x0) or capacity (0)"\r
+                               //              FreeType sets FT_Bitmap::buffer to NULL when the bitmap is empty (e.g. for ' ')\r
+                               //              JNICheck is on by default on emulators and might have a point anyway...\r
+                               //              So let's avoid this and just return a dummy non-null non-zero buffer\r
+                               return ByteBuffer.allocate(1);\r
                        return getBuffer(address);\r
                }\r
                \r