From 4e4bdc81995a9b1bc9faf2a7fb513f6aa9ad44d3 Mon Sep 17 00:00:00 2001 From: Martijn Otto Date: Thu, 8 Oct 2015 15:07:46 +0200 Subject: Fix logic error that caused segfaults for extension-created classes extended from userland using a doc-block --- zend/classimpl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3