hunspell: Partially spanify BDictReader
There's still a bit to go here, with the NUL-terminated strings embedded in the file and some other bits, and some other bits, but this is already a sizeable chunk and fixes the invalid pointer casts for reading U16s and U32s. I tried to do it all way once initially and it got pretty unwieldy. One subtlety to keep in mind when reviewing: this file used to use data == nullptr to signal an invalid dictionary. As valid dictionaries cannot be empty, I've made it check for an empty span. As part of this, I had to effectively revert https://crrev.com/c/1847603. That change did was not correct because it would sticky the first shift value it found. Additionally, these dictionaries are complex binary structures, so truncating them will just break the dictionary. BDictParser also does not seem to actually work with invalid dictionaries and we simply trust that the dictionary was valid. The spanification adds some runtime bounds checks that were previously missed. Bug: 40284755, 40248746 Change-Id: I34f466e25c43643757f804f56371cbaa8372a4f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5392006 Reviewed-by:Anthony Cui <cuianthony@chromium.org> Commit-Queue: David Benjamin <davidben@chromium.org> Cr-Commit-Position: refs/heads/main@{#1280472}
Loading
Please register or sign in to comment