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: 2020-09-22 15:30 UTC
From: willfitch@php.net Assigned: willfitch (profile)
Status: Assigned Package: Bitset (PECL)
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
39 + 45 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

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
 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Apr 02 05:03:42 2023 UTC