summaryrefslogtreecommitdiff
path: root/src/runtime/c
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/c')
-rw-r--r--src/runtime/c/gu/string.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/runtime/c/gu/string.c b/src/runtime/c/gu/string.c
index 7dc90e1e3..7ffd43068 100644
--- a/src/runtime/c/gu/string.c
+++ b/src/runtime/c/gu/string.c
@@ -352,12 +352,16 @@ gu_string_is_prefix(GuString s1, GuString s2)
str2 = (char*) &p[1];
}
- while (sz1 > 0 && sz2 > 0) {
+
+ if (sz1 > sz2)
+ return false;
+
+ for (size_t sz = sz1; sz--; sz > 0) {
if (*str1 != *str2)
return false;
- str1++; sz1--;
- str2++; sz2--;
+ str1++;
+ str2++;
}
return true;