LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: aldacron on March 10, 2004, 17:32:59

Title: Possible bug
Post by: aldacron on March 10, 2004, 17:32:59
From Keyboard.java, starting at line 404 in enableBuffer():

readBuffer = nEnableBuffer();
if (readBuffer != null)
readBuffer.order(ByteOrder.nativeOrder());
return readBuffer.capacity()/2;


The native implementation of nEnableBuffer calls env->NewDirectByteBuffer(), then returns the reference. If there really is a chance for a null reference to be returned, the the call to readBuffer.capacity() should also be inside the if block. I don't know if NewDirectByteBuffer would throw an OutOfMemoryError or not, but if it does then the null check is pointless anyway.
Title: Possible bug
Post by: Matzon on March 10, 2004, 20:50:56
yup, null check is superfluous since it will throw an exception if anything goes bad