From 8b755e327112fc1184e6dcdd20294a678f6d8f40 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 9 Oct 2012 10:54:05 +0200 Subject: Fix NPE in Buffers.slice2Float(), regression of commit 86e8c3a8d9f430700e07c485127130da68618e9d --- src/java/com/jogamp/common/nio/Buffers.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/java/com/jogamp') diff --git a/src/java/com/jogamp/common/nio/Buffers.java b/src/java/com/jogamp/common/nio/Buffers.java index aeb37e9..63f3188 100755 --- a/src/java/com/jogamp/common/nio/Buffers.java +++ b/src/java/com/jogamp/common/nio/Buffers.java @@ -279,8 +279,15 @@ public class Buffers { * @return FloatBuffer w/ native byte order as given ByteBuffer */ public static final FloatBuffer slice2Float(Buffer buf, float[] backing, int floatPos, int floatSize) { - final int pos = buf.position(); - final int limit = buf.limit(); + final int pos; + final int limit; + if(null != buf) { + pos = buf.position(); + limit = buf.limit(); + } else { + pos = 0; + limit = 0; + } final FloatBuffer res; try { if(buf instanceof ByteBuffer) { @@ -299,7 +306,9 @@ public class Buffers { throw new InternalError("Buffer not ByteBuffer, nor FloarBuffer, nor backing array given"); } } finally { - buf.position(pos).limit(limit); + if(null != buf) { + buf.position(pos).limit(limit); + } } res.mark(); return res; -- cgit v1.2.3