No free when construct was not done (#6483)
* No free when construct was not done
This fix the segfault when some other error happens
* Add more tests
* Use Sub to avoid printing too much
diff --git a/php/tests/generated_class_test.php b/php/tests/generated_class_test.php
index a9ad793..a54c4e5 100644
--- a/php/tests/generated_class_test.php
+++ b/php/tests/generated_class_test.php
@@ -1504,4 +1504,27 @@
$m = new TestMessage();
$m->setOptionalString($values[0]);
}
+
+ #########################################################
+ # Test no segfault when error happens
+ #########################################################
+
+ function throwIntendedException()
+ {
+ throw new Exception('Intended');
+ }
+
+ /**
+ * @expectedException Exception
+ */
+ public function testNoSegfaultWithError()
+ {
+ new TestMessage(['optional_int32' => $this->throwIntendedException()]);
+ }
+
+ public function testNoExceptionWithVarDump()
+ {
+ $m = new Sub(['a' => 1]);
+ var_dump($m);
+ }
}