From 58a0ee09c364c33be1765ada10d007e5b9812c5d Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 7 Jun 2005 18:11:56 +0000 Subject: [PATCH] Fixed bug #26456 (Wrong results from Reflection-API getDocComment() when called via STDIN) --- Zend/zend_compile.c | 15 +++++++++------ Zend/zend_compile.h | 11 +++++++---- Zend/zend_language_scanner.l | 3 ++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index cdd56f6c0d..76d057c54b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1155,9 +1155,10 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n } if (CG(doc_comment)) { - CG(active_op_array)->doc_comment = estrndup(CG(doc_comment), CG(doc_comment_len)); + CG(active_op_array)->doc_comment = CG(doc_comment); CG(active_op_array)->doc_comment_len = CG(doc_comment_len); - RESET_DOC_COMMENT(); + CG(doc_comment) = NULL; + CG(doc_comment_len) = 0; } } @@ -2611,9 +2612,10 @@ void zend_do_begin_class_declaration(znode *class_token, znode *class_name, znod CG(implementing_class) = opline->result; if (CG(doc_comment)) { - CG(active_class_entry)->doc_comment = estrndup(CG(doc_comment), CG(doc_comment_len)); + CG(active_class_entry)->doc_comment = CG(doc_comment); CG(active_class_entry)->doc_comment_len = CG(doc_comment_len); - RESET_DOC_COMMENT(); + CG(doc_comment) = NULL; + CG(doc_comment_len) = 0; } } @@ -2745,9 +2747,10 @@ void zend_do_declare_property(znode *var_name, znode *value, zend_uint access_ty } if (CG(doc_comment)) { - comment = estrndup(CG(doc_comment), CG(doc_comment_len)); + comment = CG(doc_comment); comment_len = CG(doc_comment_len); - RESET_DOC_COMMENT(); + CG(doc_comment) = NULL; + CG(doc_comment_len) = 0; } zend_declare_property_ex(CG(active_class_entry), var_name->u.constant.value.str.val, var_name->u.constant.value.str.len, property, access_type, comment, comment_len TSRMLS_CC); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index b5ae12ebca..205da32811 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -40,10 +40,13 @@ #define DEC_BPC(op_array) if (CG(interactive)) { ((op_array)->backpatch_count--); } #define HANDLE_INTERACTIVE() if (CG(interactive)) { execute_new_code(TSRMLS_C); } -#define RESET_DOC_COMMENT() \ - { \ - CG(doc_comment) = NULL; \ - CG(doc_comment_len) = 0; \ +#define RESET_DOC_COMMENT() \ + { \ + if (CG(doc_comment)) { \ + efree(CG(doc_comment)); \ + CG(doc_comment) = NULL; \ + } \ + CG(doc_comment_len) = 0; \ } typedef struct _zend_op_array zend_op_array; diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 350cdfa664..2ef59c3ae8 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -1485,6 +1485,7 @@ NEWLINE ("\r"|"\n"|"\r\n") "/**"{WHITESPACE} { CG(comment_start_line) = CG(zend_lineno); + RESET_DOC_COMMENT(); BEGIN(ST_DOC_COMMENT); yymore(); } @@ -1501,7 +1502,7 @@ NEWLINE ("\r"|"\n"|"\r\n") } "*/" { - CG(doc_comment) = yytext; /* no copying - intentional */ + CG(doc_comment) = estrndup(yytext, yyleng); CG(doc_comment_len) = yyleng; HANDLE_NEWLINES(yytext, yyleng); BEGIN(ST_IN_SCRIPTING); -- 2.50.1