summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn Otto <martijn.otto@copernica.com>2015-10-08 15:07:46 +0200
committerMartijn Otto <martijn.otto@copernica.com>2015-10-08 15:07:46 +0200
commit4e4bdc81995a9b1bc9faf2a7fb513f6aa9ad44d3 (patch)
tree3e8a7cf2df68812b251c5a0671e10f1d4b3cb44f
parenta41a67b8eff999aefa165237b5f06074f6446f85 (diff)
Fix logic error that caused segfaults for extension-created classes extended from userland using a doc-block
-rw-r--r--zend/classimpl.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/zend/classimpl.cpp b/zend/classimpl.cpp
index cd8c409..5c339e9 100644
--- a/zend/classimpl.cpp
+++ b/zend/classimpl.cpp
@@ -52,8 +52,13 @@ static ClassImpl *self(zend_class_entry *entry)
* Usually the doc_comment is not set (it equals the nullptr) and if it
* is set, the accompanying doc_comment_len should be non-zero to
* indicate the number of characters in it.
+ *
+ * When, however, we use the doc_comment from inside PHP-CPP to store
+ * the classimpl, we store a null-character (to immediately terminate
+ * the string, in case PHP tries to read it) and after that the pointer
+ * and we leave the doc_comment_len at 0.
*/
- while (entry->parent && entry->info.user.doc_comment == nullptr && entry->info.user.doc_comment_len == 0)
+ while (entry->parent && (entry->info.user.doc_comment == nullptr || entry->info.user.doc_comment_len > 0))
{
// we did not create this class entry, but luckily we have a parent
entry = entry->parent;