Skip to content

Commit 075b057

Browse files
committed
utf8_hop_forward: Break from loop instead of returning early
This is in preparation for a future commit where we will need to do finish-up work before returning.
1 parent a98fcf3 commit 075b057

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

inline.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,10 +2691,12 @@ Perl_utf8_hop_forward(const U8 *s, SSize_t off, const U8 *end)
26912691

26922692
while (off-- && s < end) {
26932693
STRLEN skip = UTF8SKIP(s);
2694-
if ((STRLEN)(end - s) <= skip) {
2695-
GCC_DIAG_IGNORE(-Wcast-qual)
2696-
return (U8 *)end;
2697-
GCC_DIAG_RESTORE
2694+
2695+
/* Quit without counting this character if it overshoots the edge.
2696+
* */
2697+
if ((STRLEN)(end - s) < skip) {
2698+
s = end;
2699+
break;
26982700
}
26992701
s += skip;
27002702
}

0 commit comments

Comments
 (0)