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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC