mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Corpus editor: fix random char value of UTF-8.
This commit is contained in:
parent
a9ca0e4de3
commit
31afacc7be
@ -268,12 +268,12 @@ void CorpusEditorUtf8::flip_case(vector<unichar> &corpus) {
|
|||||||
unichar CorpusEditorUtf8::chooseCodePoint(void) {
|
unichar CorpusEditorUtf8::chooseCodePoint(void) {
|
||||||
/* We need to ensure that we don't pick a surrogate cp */
|
/* We need to ensure that we don't pick a surrogate cp */
|
||||||
const u32 range =
|
const u32 range =
|
||||||
MAX_UNICODE + 1 - (UNICODE_SURROGATE_MAX + UNICODE_SURROGATE_MIN + 1);
|
MAX_UNICODE + 1 - (UNICODE_SURROGATE_MAX - UNICODE_SURROGATE_MIN + 1);
|
||||||
unichar raw = props.rand(0, range - 1);
|
unichar raw = props.rand(0, range - 1);
|
||||||
if (raw < UNICODE_SURROGATE_MIN) {
|
if (raw < UNICODE_SURROGATE_MIN) {
|
||||||
return raw;
|
return raw;
|
||||||
} else {
|
} else {
|
||||||
return raw + UNICODE_SURROGATE_MAX + 1;
|
return raw + UNICODE_SURROGATE_MAX - UNICODE_SURROGATE_MIN + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user