Fix invalid memory read
Fix crashes under Valgrind

* Fix crashes under valgrind when Zend MM is used;
* Double the number of preallocated frames (based on the longest
  execution path)
* More checks for the debug mode
Merge pull request #1994 from sjinks/1.3.0

Fix invalid memory read