Permalink
Browse files

Fixed bug #26456 (Wrong results from Reflection-API getDocComment() w…

…hen called via STDIN)
  • Loading branch information...
1 parent eaa3d6c commit 58a0ee09c364c33be1765ada10d007e5b9812c5d Dmitry Stogov committed Jun 7, 2005
Showing with 18 additions and 11 deletions.
  1. +9 −6 Zend/zend_compile.c
  2. +7 −4 Zend/zend_compile.h
  3. +2 −1 Zend/zend_language_scanner.l
View
15 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);
View
11 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;
View
3 Zend/zend_language_scanner.l
@@ -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);

0 comments on commit 58a0ee0

Please sign in to comment.