Skip to content

Commit 2110398

Browse files
committed
Fix missing return FAILURE
1 parent 82dfd93 commit 2110398

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Zend/tests/gh10765_1.phpt

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ try {
1313

1414
?>
1515
--EXPECT--
16-
setcookie(): "expires" option cannot be negative
17-
--EXPECTHEADERS--
16+
setcookie(): "expires" option must be greater than or equal to 0

Zend/tests/gh10765_2.phpt

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ try {
1313

1414
?>
1515
--EXPECT--
16-
setcookie(): "expires" option cannot be negative
17-
--EXPECTHEADERS--
16+
setcookie(): "expires" option must be greater than or equal to 0

ext/standard/head.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ PHPAPI zend_result php_setcookie(zend_string *name, zend_string *value, time_t e
117117
return FAILURE;
118118
}
119119
#endif
120+
if (UNEXPECTED(expires < 0)) {
121+
zend_value_error("%s(): \"expires\" option must be greater than or equal to 0", get_active_function_name());
122+
return FAILURE;
123+
}
120124

121125
/* Should check value of SameSite? */
122126

@@ -161,8 +165,6 @@ PHPAPI zend_result php_setcookie(zend_string *name, zend_string *value, time_t e
161165

162166
smart_str_appends(&buf, COOKIE_MAX_AGE);
163167
smart_str_append_long(&buf, (zend_long) diff);
164-
} else if (UNEXPECTED(expires < 0)) {
165-
zend_value_error("%s(): \"expires\" option cannot be negative", get_active_function_name());
166168
}
167169
}
168170

0 commit comments

Comments
 (0)