php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63315 BitSet::fromArray modifies original array value if a non-integer is supplied
Submitted: 2012-10-19 18:21 UTC Modified: 2023-05-25 06:31 UTC
From: willfitch@php.net Assigned: remi (profile)
Status: Closed Package: *General Issues
PHP Version: Irrelevant 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: willfitch@php.net
New email:
PHP Version: OS:

 

 [2012-10-19 18:21 UTC] willfitch@php.net
Description:
------------
When passing an array to BitSet::fromArray, the original array is modified when 
any of the values in the array are non-long.

Test script:
---------------
<?php

$arr = array(5, 6, '7');
var_dump($arr);
BitSet::fromArray($arr);
var_dump($arr);

?>

Expected result:
----------------
array(3) {
  [0]=>
  int(5)
  [1]=>
  int(6)
  [2]=>
  string(1) "7"
}

Actual result:
--------------
array(3) {
  [0]=>
  int(5)
  [1]=>
  int(6)
  [2]=>
  int(7)
}

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-19 18:21 UTC] willfitch@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: willfitch
 [2017-10-24 03:26 UTC] kalle@php.net
-Status: Verified +Status: Assigned
 [2020-09-22 15:30 UTC] cmb@php.net
The problem is that the array elements are convert_to_long(), what
modifies the zvals in the array.  As a quick fix, separating the
array in zpp() should solve that.
 [2020-12-23 14:10 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #63315: BitSet::fromArray may modify original array value
On GitHub:  https://github.com/php/pecl-numbers-bitset/pull/13
Patch:      https://github.com/php/pecl-numbers-bitset/pull/13.patch
 [2023-05-24 14:00 UTC] git@php.net
Automatic comment on behalf of cmb69 (author) and remicollet (committer)
Revision: https://github.com/php/pecl-numbers-bitset/commit/11bad9e1ffe0c37fd47e40505eea80e6b98c3650
Log: Fix #63315: BitSet::fromArray may modify original array value
 [2023-05-24 14:00 UTC] git@php.net
-Status: Assigned +Status: Closed
 [2023-05-25 06:31 UTC] remi@php.net
-Package: Bitset +Package: *General Issues -Assigned To: willfitch +Assigned To: remi
 [2023-05-25 06:31 UTC] remi@php.net
Fixed upstream (will be in 3.1.0)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 09:01:26 2025 UTC