Please check the length before dereferencing buffer.