]> granicus.if.org Git - php/commitdiff
Fixed bug #26456 (Wrong results from Reflection-API getDocComment() when called via...
authorDmitry Stogov <dmitry@php.net>
Tue, 7 Jun 2005 18:07:52 +0000 (18:07 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 7 Jun 2005 18:07:52 +0000 (18:07 +0000)
NEWS
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_language_scanner.l

diff --git a/NEWS b/NEWS
index e74785ecbebc9a8292d1be61a931b309b51be15e..7f5ae40e13df62f62127afb5300807f2a0fe629e 100644 (file)
--- 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
index 99d5a39886682437bb725c34143658166104ac44..a68b7cba221bf34db4468213c960b4738c4015aa 100644 (file)
@@ -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;
        }
 }
 
index 46e4af909a634f300aa8860773f48b53b3a6bc4e..e5d2faa919c395bc191c24fc36ae0b4e4fdac973 100644 (file)
 #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;
index d6f17a211189d5402b3266d64e03dfe133682fda..765bdc68d1f733910ac9d66c34ad812445a52db3 100644 (file)
@@ -1464,6 +1464,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
 
 <ST_IN_SCRIPTING>"/**"{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")
 }
 
 <ST_DOC_COMMENT>"*/" {
-       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);