Merge various clean-ups from upstream

The only functionality change here is to mouse scroll handling, which
won't affect Android as we don't use the library for mice. The other
changes are assorted cleanups including for variable-length array
issues, address sanitizer crashes, and various other small code issues.

Bug: 314743031
Test: Treehugger
Change-Id: I8655f873a13a9ba3b8ef437246c0c368f8bd1b76