Skip to content

Commit

Permalink
Merge pull request #1383 from dreamsxin/view
Browse files Browse the repository at this point in the history
Fix #1379
  • Loading branch information
Phalcon committed Oct 15, 2013
2 parents 8a466a6 + e6b6490 commit 07cfb9b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions ext/mvc/view/engine/volt/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static void phvolt_scanner_error_msg(phvolt_parser_status *parser_status, zval *
int length;
phvolt_scanner_state *state = parser_status->scanner_state;

PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
if (state->start) {
error = emalloc(sizeof(char) * 72 + state->start_length + Z_STRLEN_P(state->active_file));
if (state->start_length > 16) {
Expand Down Expand Up @@ -193,6 +193,7 @@ int phvolt_parse_view(zval *result, zval *view_code, zval *template_path TSRMLS_
if (phvolt_internal_parse_view(&result, view_code, template_path, &error_msg TSRMLS_CC) == FAILURE) {
if (likely(error_msg != NULL)) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_view_exception_ce, Z_STRVAL_P(error_msg));
zval_ptr_dtor(&error_msg);
}
else {
PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_view_exception_ce, "Error parsing the view");
Expand Down Expand Up @@ -237,7 +238,7 @@ int phvolt_internal_parse_view(zval **result, zval *view_code, zval *template_pa

/** Check if the view has code */
if (!Z_STRVAL_P(view_code)) {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "View code cannot be null", 1);
return FAILURE;
}
Expand All @@ -250,7 +251,7 @@ int phvolt_internal_parse_view(zval **result, zval *view_code, zval *template_pa
/** Start the reentrant parser */
phvolt_parser = phvolt_Alloc(phvolt_wrapper_alloc);
if (unlikely(!phvolt_parser)) {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "Memory allocation error", 1);
return FAILURE;
}
Expand Down Expand Up @@ -643,7 +644,7 @@ int phvolt_internal_parse_view(zval **result, zval *view_code, zval *template_pa
if (!*error_msg) {
error = emalloc(sizeof(char) * (48 + Z_STRLEN_P(state->active_file)));
snprintf(error, 48 + Z_STRLEN_P(state->active_file) + state->active_line, "Scanner: unknown opcode %d on in %s line %d", token.opcode, Z_STRVAL_P(state->active_file), state->active_line);
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, error, 1);
efree(error);
}
Expand Down Expand Up @@ -680,7 +681,7 @@ int phvolt_internal_parse_view(zval **result, zval *view_code, zval *template_pa
status = FAILURE;
if (parser_status->syntax_error) {
if (!*error_msg) {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, parser_status->syntax_error, 1);
}
efree(parser_status->syntax_error);
Expand Down
11 changes: 6 additions & 5 deletions ext/mvc/view/engine/volt/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -3416,7 +3416,7 @@ static void phvolt_scanner_error_msg(phvolt_parser_status *parser_status, zval *
int length;
phvolt_scanner_state *state = parser_status->scanner_state;

PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
if (state->start) {
error = emalloc(sizeof(char) * 72 + state->start_length + Z_STRLEN_P(state->active_file));
if (state->start_length > 16) {
Expand Down Expand Up @@ -3456,6 +3456,7 @@ int phvolt_parse_view(zval *result, zval *view_code, zval *template_path TSRMLS_
if (phvolt_internal_parse_view(&result, view_code, template_path, &error_msg TSRMLS_CC) == FAILURE) {
if (likely(error_msg != NULL)) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_view_exception_ce, Z_STRVAL_P(error_msg));
zval_ptr_dtor(&error_msg);
}
else {
PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_view_exception_ce, "Error parsing the view");
Expand Down Expand Up @@ -3500,7 +3501,7 @@ int phvolt_internal_parse_view(zval **result, zval *view_code, zval *template_pa

/** Check if the view has code */
if (!Z_STRVAL_P(view_code)) {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "View code cannot be null", 1);
return FAILURE;
}
Expand All @@ -3513,7 +3514,7 @@ int phvolt_internal_parse_view(zval **result, zval *view_code, zval *template_pa
/** Start the reentrant parser */
phvolt_parser = phvolt_Alloc(phvolt_wrapper_alloc);
if (unlikely(!phvolt_parser)) {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "Memory allocation error", 1);
return FAILURE;
}
Expand Down Expand Up @@ -3906,7 +3907,7 @@ int phvolt_internal_parse_view(zval **result, zval *view_code, zval *template_pa
if (!*error_msg) {
error = emalloc(sizeof(char) * (48 + Z_STRLEN_P(state->active_file)));
snprintf(error, 48 + Z_STRLEN_P(state->active_file) + state->active_line, "Scanner: unknown opcode %d on in %s line %d", token.opcode, Z_STRVAL_P(state->active_file), state->active_line);
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, error, 1);
efree(error);
}
Expand Down Expand Up @@ -3943,7 +3944,7 @@ int phvolt_internal_parse_view(zval **result, zval *view_code, zval *template_pa
status = FAILURE;
if (parser_status->syntax_error) {
if (!*error_msg) {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, parser_status->syntax_error, 1);
}
efree(parser_status->syntax_error);
Expand Down

0 comments on commit 07cfb9b

Please sign in to comment.