Skip to content

Commit

Permalink
Fixed bug #53070 (enchant_broker_get_path crashes if no path is set)
Browse files Browse the repository at this point in the history
enchant_broker_get_dict_path segfaults when the dict path is not setup,
instead of segfaulting return false instead.
  • Loading branch information
jelly authored and cmb69 committed Oct 15, 2017
1 parent fb09021 commit 5acb838
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ PHP NEWS
function). (Laruence)

- Enchant:
. Fixed bug #53070 (enchant_broker_get_path crashes if no path is set). (jelle
van der Waa, cmb)
. Fixed bug #75365 (Enchant still reports version 1.1.0). (cmb)

- Exif:
Expand Down
5 changes: 5 additions & 0 deletions ext/enchant/enchant.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
/* }}} */
Expand Down
20 changes: 20 additions & 0 deletions ext/enchant/tests/bug53070.phpt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 5acb838

Please sign in to comment.