Fix gather_uninteresting_hashes()
It can crash when the file length is an exact multiple of the page size. When the file size is not an exact page size multiple, SkData::MakeFromFileName() (i.e. mmap) happens to fill the rest with \0, giving us a terminating \0 for free. SkStrSplit() uses this to stop. When the file size is an exact page size multiple, there's no guaranteed \0. We might find one on the next page immediately, eventually, or we might just segfault. Whoops. To fix, copy to an SkString which ought to plop in a \0 for us. Change-Id: I51bbfdd85dfbb1c2276249d0255cf1c410ef9999 Reviewed-on: https://skia-review.googlesource.com/11409 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
This commit is contained in:
parent
7abfb5e154
commit
45dcc0c42c
@ -329,8 +329,12 @@ static void gather_uninteresting_hashes() {
|
||||
FLAGS_uninterestingHashesFile[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy to a string to make sure SkStrSplit has a terminating \0 to find.
|
||||
SkString contents((const char*)data->data(), data->size());
|
||||
|
||||
SkTArray<SkString> hashes;
|
||||
SkStrSplit((const char*)data->data(), kNewline, &hashes);
|
||||
SkStrSplit(contents.c_str(), kNewline, &hashes);
|
||||
for (const SkString& hash : hashes) {
|
||||
gUninterestingHashes.add(hash);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user