]> 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:11:56 +0000 (18:11 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 7 Jun 2005 18:11:56 +0000 (18:11 +0000)
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_language_scanner.l

index cdd56f6c0deff858b99ae03d3462d2561b8abe52..76d057c54b4799394b81f2fe1180113999b09b63 100644 (file)
@@ -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);
index b5ae12ebca499f090b8d7a382b43cadeeaa32a5d..205da3281130252c2625f6882f1104d10f5bc275 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 350cdfa664dd6dce4c46b36ad9249bd7c51ef0ca..2ef59c3ae86c6b6eda975a6a4956ad30d26439bb 100644 (file)
@@ -1485,6 +1485,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();
 }
@@ -1501,7 +1502,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);