Skip to content

Commit

Permalink
Merge pull request #1394 from sjinks/issue-1392
Browse files Browse the repository at this point in the history
[1.3.0] Fix #1392
  • Loading branch information
Phalcon committed Oct 19, 2013
2 parents 192aa60 + 19bdefe commit d3ed354
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/mvc/view/engine/volt/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1556,11 +1556,11 @@ PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, expression){
/**
* Left part of expression is always resolved
*/
PHALCON_INIT_NVAR(left_code);
if (phalcon_array_isset_string(expr, SS("left"))) {
PHALCON_OBS_NVAR(left);
phalcon_array_fetch_string(&left, expr, SL("left"), PH_NOISY);

PHALCON_INIT_NVAR(left_code);
phalcon_call_method_p1(left_code, this_ptr, "expression", left);
}

Expand Down Expand Up @@ -1591,11 +1591,11 @@ PHP_METHOD(Phalcon_Mvc_View_Engine_Volt_Compiler, expression){
/**
* From here, right part of expression is always resolved
*/
PHALCON_INIT_NVAR(right_code);
if (phalcon_array_isset_string(expr, SS("right"))) {
PHALCON_OBS_NVAR(right);
phalcon_array_fetch_string(&right, expr, SL("right"), PH_NOISY);

PHALCON_INIT_NVAR(right_code);
phalcon_call_method_p1(right_code, this_ptr, "expression", right);
}

Expand Down
25 changes: 25 additions & 0 deletions ext/tests/issue-1392.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
Segmentation fault in \Phalcon\Mvc\View\Engine\Volt\Compiler::expression() - https://github.com/phalcon/cphalcon/issues/1392
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php
error_reporting(error_reporting() & ~E_NOTICE);

$c = new \Phalcon\Mvc\View\Engine\Volt\Compiler();
$types = array(311, 124, 33, 42, 43, 45, 47, 37, 60, 61, 62, 126, 278, 266, 267, 270, 271, 272, 273, 274, 275, 276, 356, 361, 365, 362, 363, 309, 369, 366, 367, 368);
$passed = 0;

foreach ($types as $type) {
try {
$c->expression(array('type' => $type));
}
catch (Exception $e) {
}

++$passed;
}

assert($passed == count($types));
?>
--EXPECT--

0 comments on commit d3ed354

Please sign in to comment.