From: Dmitry Stogov Date: Tue, 7 Jun 2005 18:07:52 +0000 (+0000) Subject: Fixed bug #26456 (Wrong results from Reflection-API getDocComment() when called via... X-Git-Tag: php-5.0.5RC1~189 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d544099dcbf09a8408f76cf206146e040917f561;p=php Fixed bug #26456 (Wrong results from Reflection-API getDocComment() when called via STDIN) --- diff --git a/NEWS b/NEWS index e74785ecbe..7f5ae40e13 100644 --- a/NEWS +++ b/NEWS @@ -158,6 +158,8 @@ PHP NEWS - Fixed bug #28605 (Need to use -[m]ieee option for Alpha CPUs). (Jani) - Fixed bug #27598 (list() array key assignment causes HUGE memory leak). (Dmitry) +- Fixed bug #26456 (Wrong results from Reflection-API getDocComment() when + called via STDIN). (Dmitry) - Fixed bug #22836 (returning reference to uninitialized variable). (Dmitry) 31 Mar 2005, PHP 5.0.4 diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 99d5a39886..a68b7cba22 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1079,9 +1079,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; } } @@ -2534,9 +2535,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; } } diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 46e4af909a..e5d2faa919 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -41,10 +41,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 d6f17a2111..765bdc68d1 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -1464,6 +1464,7 @@ NEWLINE ("\r"|"\n"|"\r\n") "/**"{WHITESPACE} { CG(comment_start_line) = CG(zend_lineno); + RESET_DOC_COMMENT(); BEGIN(ST_DOC_COMMENT); yymore(); } @@ -1480,7 +1481,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);