Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0.0] Segfault with annotation parse method with CLI #6784

Closed
SachaMorard opened this issue Feb 24, 2015 · 4 comments
Closed

[2.0.0] Segfault with annotation parse method with CLI #6784

SachaMorard opened this issue Feb 24, 2015 · 4 comments

Comments

@SachaMorard
Copy link
Contributor

Hello

I'm using php56 fpm on debian distribution. I found a Segfault problem when annotation reader parse a class, only with CLI (the bug appear with osx with http too)
Parse method crashes when a simple comment (without any docblock syntax) is in the class.

Try to execute this script with PHP CLI and you'll see:

/**
 * Class testclass
 * @Source('db', 'testclass')
 */
class testclass
{
    /**
     * @return string
     */
    public function hello()
    {
        return 'hello';
    }

    /**
     * Method2
     */
    public function hello2()
    {
        return 'hello';
    }
}

$annotations = new \Phalcon\Annotations\Adapter\Memory();
$reader = $annotations->getReader();
$result = $reader->parse('testclass');
var_dump($result);

It seems the problem comes from phannot_internal_parse_annotations method in phalcon.c script

Is anyone is abble to fix this issue ?

@SachaMorard
Copy link
Contributor Author

up

@kjdev
Copy link
Contributor

kjdev commented Mar 9, 2015

I think to be able to run in this patch.
It is is php5.6.6 was confirmed.

--- a/cphalcon/ext/phalcon/annotations/parser.c
+++ b/cphalcon/ext/phalcon/annotations/parser.c
@@ -1440,7 +1440,7 @@

    if (Z_STRLEN(processed_comment) < 2) {
        ZVAL_BOOL(*result, 0);
-       efree(Z_STRVAL(processed_comment));
+       str_efree(Z_STRVAL(processed_comment));
        return SUCCESS;
    }

@SachaMorard
Copy link
Contributor Author

Hi
Thank you very much, it's working perfectly ! Could you submit a PR ?

Sacha

@kjdev
Copy link
Contributor

kjdev commented Mar 10, 2015

I'm going to submit a PR is from sure that no other version (5.5etc).

kjdev pushed a commit to karakurihiden/cphalcon that referenced this issue Mar 11, 2015
phalcon pushed a commit that referenced this issue Mar 11, 2015
@phalcon phalcon closed this as completed Mar 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants