/* Single character search can shortcut memcmps
Can also avoid tolower emallocs */
if (offset >= 0) {
- if (offset > haystack->len) {
+ if ((size_t)offset > haystack->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
e = haystack->val + haystack->len - 1;
} else {
p = haystack->val;
- if (offset < -INT_MAX || -offset > haystack->len) {
+ if (offset < -INT_MAX || (size_t)(-offset) > haystack->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
php_strtolower(haystack_dup, haystack->len);
if (offset >= 0) {
- if (offset > haystack->len) {
+ if ((size_t)offset > haystack->len) {
efree(needle_dup);
efree(haystack_dup);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
p = haystack_dup + offset;
e = haystack_dup + haystack->len - needle_len;
} else {
- if (offset < -INT_MAX || -offset > haystack->len) {
+ if (offset < -INT_MAX || (size_t)(-offset) > haystack->len) {
efree(needle_dup);
efree(haystack_dup);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
p = haystack_dup;
- if (needle_len > -offset) {
+ if (needle_len > (size_t)(-offset)) {
e = haystack_dup + haystack->len - needle_len;
} else {
e = haystack_dup + haystack->len + offset;
RETURN_FALSE;
}
- if (chunklen > str->len) {
+ if ((size_t)chunklen > str->len) {
/* to maintain BC, we must return original string + ending */
result = zend_string_alloc(endlen + str->len, 0);
memcpy(result->val, str->val, str->len);
RETURN_EMPTY_STRING();
}
- result = php_chunk_split(str->val, str->len, end, endlen, chunklen);
+ result = php_chunk_split(str->val, str->len, end, endlen, (size_t)chunklen);
if (result) {
RETURN_STR(result);
#endif
if (argc > 2) {
- if ((l < 0 && -l > str->len)) {
+ if ((l < 0 && (size_t)(-l) > str->len)) {
RETURN_FALSE;
} else if (l > (zend_long)str->len) {
l = str->len;
zval result;
zend_string *string_key;
zend_ulong num_key;
- zend_long count = 0;
+ size_t count = 0;
int argc = ZEND_NUM_ARGS();
#ifndef FAST_ZPP
RETURN_FALSE;
}
- if (offset > haystack_len) {
+ if ((size_t)offset > haystack_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset value " ZEND_LONG_FMT " exceeds string length", offset);
RETURN_FALSE;
}
/* If resulting string turns out to be shorter than input string,
we simply copy the input and return. */
- if (pad_length < 0 || pad_length <= input->len) {
+ if (pad_length < 0 || (size_t)pad_length <= input->len) {
RETURN_STRINGL(input->val, input->len);
}
}
- if (0 == str->len || split_length >= str->len) {
+ if (0 == str->len || (size_t)split_length >= str->len) {
array_init_size(return_value, 1);
add_next_index_stringl(return_value, str->val, str->len);
return;
offset = (offset < 0) ? 0 : offset;
}
- if (offset >= s1->len) {
+ if ((size_t)offset >= s1->len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The start position cannot exceed initial string length");
RETURN_FALSE;
}