Use size_t for lengths in FX_strstr().
As would be flagged by -Wshorten-64-to-32
Change-Id: I1a5867b9caa207059d837dea200b9ae68e9b7b4b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/86896
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index 2472761..ef3abb6 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -36,23 +36,22 @@
constexpr char kTrimChars[] = "\x09\x0a\x0b\x0c\x0d\x20";
const char* FX_strstr(const char* haystack,
- int haystack_len,
+ size_t haystack_len,
const char* needle,
- int needle_len) {
- if (needle_len > haystack_len || needle_len == 0) {
+ size_t needle_len) {
+ if (needle_len > haystack_len || needle_len == 0)
return nullptr;
- }
+
const char* end_ptr = haystack + haystack_len - needle_len;
while (haystack <= end_ptr) {
- int i = 0;
+ size_t i = 0;
while (1) {
- if (haystack[i] != needle[i]) {
+ if (haystack[i] != needle[i])
break;
- }
+
i++;
- if (i == needle_len) {
+ if (i == needle_len)
return haystack;
- }
}
haystack++;
}