php.net |  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: 2020-06-28 08:17 UTC
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:1 (25.0%)
From: dave at synchtank dot net Assigned: omars (profile)
Status: Assigned Package: solr (PECL)
PHP Version: 7.0.16 OS: Ubuntu 16 LTS
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: dave at synchtank dot net
New email:
PHP Version: OS:

 

 [2017-03-08 23:27 UTC] dave at synchtank dot net
Description:
------------
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:
---------------
<?php
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();

$query->setQuery('*:*');

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

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

Expected result:
----------------
segfault


Patches

Pull Requests

History

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..
 [2019-03-29 09:36 UTC] omars@php.net
-Assigned To: +Assigned To: omars
 [2020-06-28 08:17 UTC] omars@php.net
will try to address in 2.5.1
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 18:01:29 2024 UTC