Just a guess, but are you sure that the variables other than the byte array and it's length are correct/pointing to the right things?