Possible bug

Started by aldacron, March 10, 2004, 17:32:59

Previous topic - Next topic

aldacron

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.

Matzon

yup, null check is superfluous since it will throw an exception if anything goes bad