php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72998 readline segfaults php on empty array returned from callback
Submitted: 2016-09-01 21:04 UTC Modified: 2016-09-03 15:59 UTC
From: lindsay at notion dot ai Assigned:
Status: Open Package: Readline related
PHP Version: 7.0.10 OS: Ubuntu 14.04.3 LTS
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-09-01 21:04 UTC] lindsay at notion dot ai
Description:
------------
If the callback for readline_completion_function returns an empty array, php will segfault.

When running the example code, hit tab to fire the callback.

Test script:
---------------
<?php

readline_completion_function('readline_callback');

do
{
	$command = readline('> ');
	echo 'command: ' . $command . PHP_EOL;
} while ($command);

function readline_callback($command)
{
	return [];
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-02 22:16 UTC] lindsay at notion dot ai
-Operating System: osx 10.11.6 +Operating System: Ubuntu 14.04.3 LTS
 [2016-09-02 22:16 UTC] lindsay at notion dot ai
Incorrectly submitted ticket with my desktop os as osx.  I'm actually running this on linux ubuntu 14.04 kernel 3.19.0-25
 [2016-09-03 15:59 UTC] laruence@php.net
I think this is libedit bug, (you are using libedit, right?) 

https://github.com/ThomasAdam/libedit/blob/cabe0cf6a78a93fc9389e5fe1e3814790a6d8787/src/filecomplete.c#L358

seems it doesn't expect to accept an return like ["", NULL];
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 16:01:26 2019 UTC