8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ee9ea1 commit 58d35ffCopy full SHA for 58d35ff
algorithms/cpp/UTF8Validation/UTF8Validation.cpp
@@ -67,6 +67,10 @@ class Solution {
67
return false;
68
}
69
70
+ // invalid utf-8 as it doesn't have enough 10xxxxxx
71
+ if (i + len > data.size()) {
72
+ return false;
73
+ }
74
75
for (int j=i+1; j < i+len; j++) { //checking 10xxxxxx
76
if ( (data[j] & 0xC0) != 0x80 ) {
@@ -75,11 +79,6 @@ class Solution {
79
80
77
81
i += len ;
78
-
- if (i > data.size()) {
- return false;
- }
82
83
84
return true;
85
0 commit comments