Skip to content

Commit

Permalink
Merge pull request #1389 from sjinks/issue-1379
Browse files Browse the repository at this point in the history
Fix #1379 completely
  • Loading branch information
Phalcon committed Oct 17, 2013
2 parents 48d7ce3 + a7e7cc5 commit a326eb0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
6 changes: 3 additions & 3 deletions ext/annotations/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void phannot_scanner_error_msg(phannot_parser_status *parser_status, zval
char *error, *error_part;
phannot_scanner_state *state = parser_status->scanner_state;

PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
if (state->start) {
error_length = 128 + state->start_length + Z_STRLEN_P(state->active_file);
error = emalloc(sizeof(char) * error_length);
Expand Down Expand Up @@ -377,7 +377,7 @@ int phannot_internal_parse_annotations(zval **result, zval *comment, zval *file_
error = emalloc(error_length);
snprintf(error, error_length - 1, "Scanner: unknown opcode %d on in %s line %d", token.opcode, Z_STRVAL_P(state->active_file), state->active_line);
error[error_length - 1] = '\0';
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, error, 1);
efree(error);
}
Expand Down Expand Up @@ -413,7 +413,7 @@ int phannot_internal_parse_annotations(zval **result, zval *comment, zval *file_
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
6 changes: 3 additions & 3 deletions ext/annotations/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ static void phannot_scanner_error_msg(phannot_parser_status *parser_status, zval
char *error, *error_part;
phannot_scanner_state *state = parser_status->scanner_state;

PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
if (state->start) {
error_length = 128 + state->start_length + Z_STRLEN_P(state->active_file);
error = emalloc(sizeof(char) * error_length);
Expand Down Expand Up @@ -1571,7 +1571,7 @@ int phannot_internal_parse_annotations(zval **result, zval *comment, zval *file_
error = emalloc(error_length);
snprintf(error, error_length - 1, "Scanner: unknown opcode %d on in %s line %d", token.opcode, Z_STRVAL_P(state->active_file), state->active_line);
error[error_length - 1] = '\0';
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, error, 1);
efree(error);
}
Expand Down Expand Up @@ -1607,7 +1607,7 @@ int phannot_internal_parse_annotations(zval **result, zval *comment, zval *file_
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
20 changes: 10 additions & 10 deletions ext/mvc/model/query/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ PHALCON_ATTR_NONNULL static void phql_scanner_error_msg(phql_parser_status *pars
unsigned int length;
phql_scanner_state *state = parser_status->scanner_state;

PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
if (state->start) {
length = 64 + state->start_length + parser_status->phql_length;
error = emalloc(sizeof(char) * length);
Expand Down Expand Up @@ -182,7 +182,7 @@ PHALCON_ATTR_NONNULL2(1, 4) int phql_internal_parse_phql(zval **result, char *ph
zval **temp_ast;

if (!phql) {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "PHQL statement cannot be NULL", 1);
return FAILURE;
}
Expand All @@ -203,7 +203,7 @@ PHALCON_ATTR_NONNULL2(1, 4) int phql_internal_parse_phql(zval **result, char *ph

phql_parser = phql_Alloc(phql_wrapper_alloc);
if (unlikely(!phql_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 @@ -325,7 +325,7 @@ PHALCON_ATTR_NONNULL2(1, 4) int phql_internal_parse_phql(zval **result, char *ph
if (parser_status->enable_literals) {
phql_parse_with_token(phql_parser, PHQL_T_INTEGER, PHQL_INTEGER, &token, parser_status);
} else {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1);
parser_status->status = PHQL_PARSING_FAILED;
}
Expand All @@ -334,7 +334,7 @@ PHALCON_ATTR_NONNULL2(1, 4) int phql_internal_parse_phql(zval **result, char *ph
if (parser_status->enable_literals) {
phql_parse_with_token(phql_parser, PHQL_T_DOUBLE, PHQL_DOUBLE, &token, parser_status);
} else {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1);
parser_status->status = PHQL_PARSING_FAILED;
}
Expand All @@ -343,7 +343,7 @@ PHALCON_ATTR_NONNULL2(1, 4) int phql_internal_parse_phql(zval **result, char *ph
if (parser_status->enable_literals) {
phql_parse_with_token(phql_parser, PHQL_T_STRING, PHQL_STRING, &token, parser_status);
} else {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1);
parser_status->status = PHQL_PARSING_FAILED;
}
Expand All @@ -352,7 +352,7 @@ PHALCON_ATTR_NONNULL2(1, 4) int phql_internal_parse_phql(zval **result, char *ph
if (parser_status->enable_literals) {
phql_(phql_parser, PHQL_TRUE, NULL, parser_status);
} else {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1);
parser_status->status = PHQL_PARSING_FAILED;
}
Expand All @@ -361,7 +361,7 @@ PHALCON_ATTR_NONNULL2(1, 4) int phql_internal_parse_phql(zval **result, char *ph
if (parser_status->enable_literals) {
phql_(phql_parser, PHQL_FALSE, NULL, parser_status);
} else {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1);
parser_status->status = PHQL_PARSING_FAILED;
}
Expand Down Expand Up @@ -488,7 +488,7 @@ PHALCON_ATTR_NONNULL2(1, 4) int phql_internal_parse_phql(zval **result, char *ph
error = emalloc(error_length);
snprintf(error, error_length, "Scanner: Unknown opcode %c", token.opcode);
error[error_length - 1] = '\0';
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, error, 1);
efree(error);
break;
Expand Down Expand Up @@ -525,7 +525,7 @@ PHALCON_ATTR_NONNULL2(1, 4) int phql_internal_parse_phql(zval **result, char *ph
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
21 changes: 11 additions & 10 deletions ext/mvc/model/query/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2779,7 +2779,7 @@ PHALCON_ATTR_NONNULL static void phql_scanner_error_msg(phql_parser_status *pars
unsigned int length;
phql_scanner_state *state = parser_status->scanner_state;

PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
if (state->start) {
length = 64 + state->start_length + parser_status->phql_length;
error = emalloc(sizeof(char) * length);
Expand Down Expand Up @@ -2813,6 +2813,7 @@ PHALCON_ATTR_NONNULL int phql_parse_phql(zval *result, zval *phql TSRMLS_DC) {
if (phql_internal_parse_phql(&result, Z_STRVAL_P(phql), Z_STRLEN_P(phql), &error_msg TSRMLS_CC) == FAILURE) {
if (likely(error_msg != NULL)) {
PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_model_exception_ce, Z_STRVAL_P(error_msg));
zval_ptr_dtor(&error_msg);
}
else {
PHALCON_THROW_EXCEPTION_STRW(phalcon_mvc_model_exception_ce, "There was an error parsing PHQL");
Expand Down Expand Up @@ -2840,7 +2841,7 @@ int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length
zval **temp_ast;

if (!phql) {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "PHQL statement cannot be NULL", 1);
return FAILURE;
}
Expand All @@ -2861,7 +2862,7 @@ int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length

phql_parser = phql_Alloc(phql_wrapper_alloc);
if (unlikely(!phql_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 @@ -2983,7 +2984,7 @@ int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length
if (parser_status->enable_literals) {
phql_parse_with_token(phql_parser, PHQL_T_INTEGER, PHQL_INTEGER, &token, parser_status);
} else {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1);
parser_status->status = PHQL_PARSING_FAILED;
}
Expand All @@ -2992,7 +2993,7 @@ int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length
if (parser_status->enable_literals) {
phql_parse_with_token(phql_parser, PHQL_T_DOUBLE, PHQL_DOUBLE, &token, parser_status);
} else {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1);
parser_status->status = PHQL_PARSING_FAILED;
}
Expand All @@ -3001,7 +3002,7 @@ int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length
if (parser_status->enable_literals) {
phql_parse_with_token(phql_parser, PHQL_T_STRING, PHQL_STRING, &token, parser_status);
} else {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1);
parser_status->status = PHQL_PARSING_FAILED;
}
Expand All @@ -3010,7 +3011,7 @@ int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length
if (parser_status->enable_literals) {
phql_(phql_parser, PHQL_TRUE, NULL, parser_status);
} else {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1);
parser_status->status = PHQL_PARSING_FAILED;
}
Expand All @@ -3019,7 +3020,7 @@ int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length
if (parser_status->enable_literals) {
phql_(phql_parser, PHQL_FALSE, NULL, parser_status);
} else {
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements", 1);
parser_status->status = PHQL_PARSING_FAILED;
}
Expand Down Expand Up @@ -3146,7 +3147,7 @@ int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length
error = emalloc(error_length);
snprintf(error, error_length, "Scanner: Unknown opcode %c", token.opcode);
error[error_length - 1] = '\0';
PHALCON_INIT_VAR(*error_msg);
MAKE_STD_ZVAL(*error_msg);
ZVAL_STRING(*error_msg, error, 1);
efree(error);
break;
Expand Down Expand Up @@ -3183,7 +3184,7 @@ int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length
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 a326eb0

Please sign in to comment.