php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81379 gmp_init() not accepting GMP values despite saying so
Submitted: 2021-08-24 11:37 UTC Modified: 2023-09-27 15:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: michelbach94 at gmail dot com Assigned: nielsdos (profile)
Status: Closed Package: GNU MP related
PHP Version: 8.0.9 OS: Manjaro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: michelbach94 at gmail dot com
New email:
PHP Version: OS:

 

 [2021-08-24 11:37 UTC] michelbach94 at gmail dot com
Description:
------------
gmp_init() is documented to only accept strings and ints. However, its error message says that it also accepts GMP objects while simultaneously saying it does not.

Test script:
---------------
php > gmp_init(gmp_init(5));
PHP Warning:  Uncaught TypeError: gmp_init(): Argument #1 ($num) must be of type GMP|string|int, GMP given in php shell code:1
Stack trace:
#0 php shell code(1): gmp_init(Object(GMP))
#1 {main}
  thrown in php shell code on line 1


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-24 12:10 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2021-08-24 12:10 UTC] cmb@php.net
Indeed.  The problem is that convert_to_gmp() is used to convert
the arguments of several GMP functions, and all of them but
gmp_init() actually accept GMP instances.  Maybe just accept GMP
instances for gmp_init() as well?
 [2021-08-24 13:12 UTC] nikic@php.net
I'm okay with accepting GMP in gmp_init().
 [2023-09-27 15:00 UTC] nielsdos@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: nielsdos
 [2023-09-27 15:00 UTC] nielsdos@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at
http://www.php.net/downloads.php

Seems to have been fixed in 8.1.11 & 8.2.10
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 00:01:28 2024 UTC