php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75539 Recursive call errors are not reported by preg_last_error()
Submitted: 2017-11-20 00:47 UTC Modified: -
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: grzegorz129 at gmail dot com Assigned:
Status: Closed Package: PCRE related
PHP Version: 7.2.0RC6 OS: N/A
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: grzegorz129 at gmail dot com
New email:
PHP Version: OS:

 

 [2017-11-20 00:47 UTC] grzegorz129 at gmail dot com
Description:
------------
I found a strange (yet consistent across since 5.6) regarding infinite loop patterns error reporting. preg_match() correctly identifies broken patterns and triggers E_WARN, however preg_last_error() returns PREG_NO_ERROR instead of expected PREG_RECURSION_LIMIT_ERROR.

It may be related to https://bugs.php.net/bug.php?id=74183

Test script:
---------------
<?php
// Test at https://3v4l.org/UkeMa

var_dump(preg_match('/((?1)?z)/', ''));
var_dump(preg_last_error() === \PREG_NO_ERROR);

Expected result:
----------------
- preg_match() returning false
- preg_last_error() returning value of PREG_RECURSION_LIMIT_ERROR

Actual result:
--------------
- preg_match() returns false
- preg_last_error() returns value of PREG_NO_ERROR

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-11-21 11:45 UTC] andrew dot nester dot dev at gmail dot com
Thanks for reporting this issue! I've just added PR fixing this
 [2017-11-21 19:28 UTC] ab@php.net
Automatic comment on behalf of andrew.nester.dev@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8fdef981ef940dfc2f1b21cfa3f227150472ad2d
Log: Fixed #75539 and #74183 - preg_last_error not returning error code after error
 [2017-11-21 19:28 UTC] ab@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 18:01:30 2024 UTC