php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #345 implode() segfaults when given empty array
Submitted: 1998-05-04 18:10 UTC Modified: 1998-05-04 18:47 UTC
From: torben at coastnet dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0 Latest CVS OS: Linux 2.0.33 Slackware
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: torben at coastnet dot com
New email:
PHP Version: OS:

 

 [1998-05-04 18:10 UTC] torben at coastnet dot com
implode() reliably segfaults when passed an empty array; 
the following patch fixes it (for me):

158c158
<       /* convert everything to strings, and calculate length */
---
>     /* check for empty array passed in */
160c160,165
<       while (hash_get_current_data(arr->value.ht, (void **) &tmp) == SUCCESS) {
---
>       if (hash_get_current_data(arr->value.ht, (void **) &tmp) != SUCCESS) {
>               return;
>     }
>
>       /* convert everything to strings, and calculate length */
>     do {
168c173,174
<       }
---
>       } while (hash_get_current_data(arr->value.ht, (void **) &tmp) == SUCCESS);
>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-05-04 18:47 UTC] zeev
len was being set to negative values in this case, which
caused the return value handling code to crash as soon
as the function ended.  Fixed.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 21:01:27 2025 UTC