Fix segfault on uv_fs_readlink() where target is not a link

This commit is contained in:
Bob Weinand 2019-05-04 00:17:24 +02:00
parent c06742a558
commit 63fa7f1609
4 changed files with 31 additions and 6 deletions

View File

@ -10,11 +10,11 @@
<email>bobwei9@hotmail.com</email>
<active>yes</active>
</lead>
<date>2019-04-28</date>
<date>2019-05-01</date>
<time>13:00:00</time>
<version>
<release>0.2.3</release>
<api>0.2.3</api>
<release>0.2.4</release>
<api>0.2.4</api>
</version>
<stability>
<release>beta</release>
@ -23,7 +23,6 @@
<license uri="http://www.php.net/license">PHP License</license>
<notes>
- Fix Windows build
- Fix PHP 7.4 build
</notes>
<contents>
<dir name="/">

View File

@ -1873,7 +1873,11 @@ static void php_uv_fs_cb(uv_fs_t* req)
case UV_FS_READLINK:
argc = 2;
ZVAL_BOOL(&params[0], uv->uv.fs.result == 0);
ZVAL_STRING(&params[1], req->ptr);
if (uv->uv.fs.result == 0) {
ZVAL_STRING(&params[1], req->ptr);
} else {
ZVAL_NULL(&params[1]);
}
break;
case UV_FS_READ:

View File

@ -3,7 +3,7 @@
#define PHP_UV_H
#define PHP_UV_EXTNAME "uv"
#define PHP_UV_VERSION "0.2.3"
#define PHP_UV_VERSION "0.2.4"
#ifdef HAVE_CONFIG_H
#include "config.h"

View File

@ -0,0 +1,22 @@
--TEST--
uv_fs_readlink() segfaults if file not a link
--FILE--
<?php
$uv = uv_loop_new();
uv_fs_readlink($uv, __FILE__, function () {
var_dump(func_get_args());
});
uv_run($uv);
?>
--EXPECT--
array(2) {
[0]=>
bool(false)
[1]=>
NULL
}