throw exceptions when dictionary not load success

This commit is contained in:
dongyado 2017-08-19 16:19:19 +08:00
parent 18e0c79693
commit 01f3da3375
2 changed files with 14 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#endif
#include "php.h"
#include <zend_exceptions.h>
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_friso.h"
@ -290,6 +291,15 @@ PHP_FUNCTION(friso_split)
task = friso_new_task();
idx = 0;
friso_set_text(task, _str);
if (friso_globals.friso->dic == NULL) {
zend_throw_exception(zend_exception_get_default(TSRMLS_C),
"[Error] Can not load dictionry with lex_dir from friso.ini, please check the ini file", 0 TSRMLS_CC);
RETURN_BOOL(0);
}
while ( config->next_token( friso_globals.friso, config, task ) != NULL )
{
MAKE_STD_ZVAL(item);

View File

@ -21,6 +21,7 @@
#endif
#include "php.h"
#include <zend_exceptions.h>
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_friso.h"
@ -332,6 +333,9 @@ PHP_FUNCTION(friso_split)
// to prevent segfault error when dic file not configure correct
if (friso_globals.friso->dic == NULL) {
zend_throw_exception(zend_exception_get_default(TSRMLS_C),
"[Error] can not load dictionry with lex_dir from ini file, please check the friso.ini", 0 TSRMLS_CC);
RETURN_BOOL(0);
}