]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Corpus editor: fix random char value of UTF-8.
authorChang, Harry <harry.chang@intel.com>
Thu, 12 May 2022 08:20:29 +0000 (08:20 +0000)
committerKonstantinos Margaritis <konstantinos@vectorcamp.gr>
Mon, 29 Aug 2022 12:03:30 +0000 (15:03 +0300)
util/ng_corpus_editor.cpp

index ac4f8b65405fef32bb91e7197f68d2ceaf9c6c24..c1149216dee71bc13ee70f8be3633a0381c4b7ff 100644 (file)
@@ -268,12 +268,12 @@ void CorpusEditorUtf8::flip_case(vector<unichar> &corpus) {
 unichar CorpusEditorUtf8::chooseCodePoint(void) {
     /* We need to ensure that we don't pick a surrogate cp */
     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);
     if (raw < UNICODE_SURROGATE_MIN) {
         return raw;
     } else {
-        return raw + UNICODE_SURROGATE_MAX + 1;
+        return raw + UNICODE_SURROGATE_MAX - UNICODE_SURROGATE_MIN + 1;
     }
 }