diff options
author | Sven Gothel <[email protected]> | 2012-10-09 10:54:05 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-10-09 10:54:05 +0200 |
commit | 8b755e327112fc1184e6dcdd20294a678f6d8f40 (patch) | |
tree | 23452fc70a82d68d34dfa8c54d4ebc6d62ad4b65 /src | |
parent | 86e8c3a8d9f430700e07c485127130da68618e9d (diff) |
Fix NPE in Buffers.slice2Float(), regression of commit 86e8c3a8d9f430700e07c485127130da68618e9d
Diffstat (limited to 'src')
-rwxr-xr-x | src/java/com/jogamp/common/nio/Buffers.java | 15 |
1 files changed, 12 insertions, 3 deletions
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; |