php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46920 preg_* fails with long matches
Submitted: 2008-12-21 22:26 UTC Modified: 2008-12-22 12:57 UTC
From: gdiego at gmail dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.8 OS: linux
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gdiego at gmail dot com
New email:
PHP Version: OS:

 

 [2008-12-21 22:26 UTC] gdiego at gmail dot com
Description:
------------
If the match for a regex is very long, it fails.

Reproduce code:
---------------
$a='A';
for ($i = 0; $i < 1024; $i++) $a.='a';
$a.='A';
var_dump(preg_match('/A(.*?)A/', $a, $m));

$a='A';
for ($i = 0; $i < 131072; $i++) $a.='a';
$a.='A';
var_dump(preg_match('/A(.*?)A/', $a, $m));



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


Actual result:
--------------
int(1)
int(0)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-22 12:23 UTC] scottmac@php.net
Check preg_last_error(), you've reached one of the limits set which both are 10,000 by default.

http://www.php.net/manual/en/pcre.configuration.php
 [2008-12-22 12:23 UTC] scottmac@php.net
Check preg_last_error(), you've reached one of the limits set which both are 10,000 by default.

http://www.php.net/manual/en/pcre.configuration.php
 [2008-12-22 12:23 UTC] scottmac@php.net
Check preg_last_error(), you've reached one of the limits set which both are 10,000 by default.

http://www.php.net/manual/en/pcre.configuration.php
 [2008-12-22 12:57 UTC] scottmac@php.net
Check preg_last_error(), you've reached one of the limits set which both are 10,000 by default.

http://www.php.net/manual/en/pcre.configuration.php
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Aug 11 11:00:02 2025 UTC