Skip to content
Commit 87df9bd1 authored by David Benjamin's avatar David Benjamin Committed by Chromium LUCI CQ
Browse files

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: default avatarAnthony Cui <cuianthony@chromium.org>
Commit-Queue: David Benjamin <davidben@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1280472}
parent 2cdc96d6
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment