php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43482 Inconsistent behavior in array_pad() function.
Submitted: 2007-12-03 11:07 UTC Modified: 2007-12-03 14:13 UTC
From: dharma dot yp at in dot ibm dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 5.2CVS-2007-12-03 (snap) OS: Linux
Private report: No CVE-ID: None
 [2007-12-03 11:07 UTC] dharma dot yp at in dot ibm dot com
Description:
------------
When a negative value of -12345678900 is passed for pad_size argument of array_pad(), the function doesn't produce a warning in Linux environment but a warning message is output on Windows. Whereas, when a positive value of the above, i.e. 12345678900 is passed for pad_size argument, warning message is output on both Linux and windows. This behavior is observed in the testcase array_pad_variation2.phpt on Linux environment. Could you explain the reason behind this inconsistent behavior.

This is applicable to PHP5.3 and PHP6 as well.

Reproduce code:
---------------
<?php
$arr = array(1);
var_dump( array_pad($arr, 12345678900, "hello") );  // warning generated
var_dump( array_pad($arr, -12345678900, "hello") );  // no warning
?>



Expected result:
----------------
Warning: array_pad(): You may only pad up to 1048576 elements at a time in %s on line %d
bool(false)

Warning: array_pad(): You may only pad up to 1048576 elements at a time in %s on line %d
bool(false)

Actual result:
--------------
Warning: array_pad(): You may only pad up to 1048576 elements at a time in %s on line %d
bool(false)
array(1) {
  [0]=>
  int(1)
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-03 13:45 UTC] iliaa@php.net
Works fine in CVS, I've just tried it, both 5.3 and 5.2 return FALSE + 
warning in both cases.
 [2007-12-03 13:45 UTC] iliaa@php.net
Are you running the test on 32 bit system by any chance?
 [2007-12-03 14:13 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC