|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74227 Leaving json_last_error() in an error state causes getResponse() to segfault
Submitted: 2017-03-08 23:27 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: dave at synchtank dot net Assigned:
Status: Open Package: solr (PECL)
PHP Version: 7.0.16 OS: Ubuntu 16 LTS
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-03-08 23:27 UTC] dave at synchtank dot net
If json_last_error() returns an error state, calling getResponse() causes a segfault.

Clearing json_last_error() by performing a successful json_decode or json_encode prevents the segfault.

I'm on solr 2.4.0 and PHP Version 7.0.15-0ubuntu0.16.04.4, the latest package from Ubuntu 16 LTS.

Test script:
json_decode("", true);

// uncommnt below to prevent segfault
// json_decode("[1]");

$client = new SolrClient(array('hostname' => 'myhost', 'port' => 'myport', 'path' => 'mypath', 'wt' => 'json'));

$query = new SolrQuery();


$response = $client->query($query);

// results in segfault
$results = $response->getResponse();

Expected result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-16 19:33 UTC] jochen dot weber80 at gmail dot com
I can confirm this bug. I just updated from ext version 2.1.0 to 2.4.0 and run into the same issue and the the workaround helps..
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Fri Oct 19 09:01:25 2018 UTC