php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78853 preg_match() may return integer > 1
Submitted: 2019-11-21 11:51 UTC Modified: 2019-11-21 11:51 UTC
From: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: PCRE related
PHP Version: 7.3.12 OS: *
Private report: No CVE-ID: None
 [2019-11-21 11:51 UTC] cmb@php.net
Description:
------------
As of PHP 7.3.0, preg_match() may return an integer greater than
one on success[1], although the documentation states[2]:

| preg_match() returns 1 if the pattern matches given subject, […]

This issue has been reported by Falko Matthies.

[1] <https://3v4l.org/cKarY>
[2] <https://www.php.net/manual/en/function.preg-match.php#refsect1-function.preg-match-returnvalues>


Test script:
---------------
var_dump(preg_match('/^|\d{1,2}$/', "7"));


Expected result:
----------------
int(1)

Actual result:
--------------
int(2)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-11-21 11:51 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2019-11-22 18:31 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e1da72bdf18aa3d413c5324bccfd8dc521c217e3
Log: Fix #78853: preg_match() may return integer &gt; 1
 [2019-11-22 18:31 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC