diff options
author | Jelle van der Waa <jelle@vdwaa.nl> | 2017-10-09 20:35:53 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2017-10-15 13:57:44 +0200 |
commit | 5acb8381b22f4acf629d8fc89b4e0872f1a0825c (patch) | |
tree | 79d07cc0d5cd5d205f114dd93bb241d5309ceed1 /ext/enchant | |
parent | fb0902143291c8b605997a6b2a8f8717289a44d1 (diff) | |
download | php-git-5acb8381b22f4acf629d8fc89b4e0872f1a0825c.tar.gz |
Fixed bug #53070 (enchant_broker_get_path crashes if no path is set)
enchant_broker_get_dict_path segfaults when the dict path is not setup,
instead of segfaulting return false instead.
Diffstat (limited to 'ext/enchant')
-rw-r--r-- | ext/enchant/enchant.c | 5 | ||||
-rw-r--r-- | ext/enchant/tests/bug53070.phpt | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c index 88993b3014..cd376a1aeb 100644 --- a/ext/enchant/enchant.c +++ b/ext/enchant/enchant.c @@ -482,6 +482,11 @@ PHP_FUNCTION(enchant_broker_get_dict_path) RETURN_FALSE; } + if (value == NULL) { + php_error_docref(NULL, E_WARNING, "dict_path not set"); + RETURN_FALSE; + } + RETURN_STRING(value); } /* }}} */ diff --git a/ext/enchant/tests/bug53070.phpt b/ext/enchant/tests/bug53070.phpt new file mode 100644 index 0000000000..2183960716 --- /dev/null +++ b/ext/enchant/tests/bug53070.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #53070 (enchant_broker_get_path crashes if no path is set) +--SKIPIF-- +<?php +if(!extension_loaded('enchant')) die('skip, enchant not loader'); +if (!is_resource(enchant_broker_init())) {die("skip, resource dont load\n");} +?> +--FILE-- +<?php +$broker = enchant_broker_init(); +var_dump(enchant_broker_get_dict_path($broker, ENCHANT_MYSPELL)); +var_dump(enchant_broker_get_dict_path($broker, ENCHANT_ISPELL)); +?> +--EXPECTF-- + +Warning: enchant_broker_get_dict_path(): dict_path not set in %s on line %d +bool(false) + +Warning: enchant_broker_get_dict_path(): dict_path not set in %s on line %d +bool(false) |