From a71762d4ded9ebd8121dfdc8d2af2dbebb5cc3c7 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Sat, 28 Feb 2015 15:59:52 +0000 Subject: [PATCH] Fixed issue #1117: Path/branch coverage sometimes crashes --- xdebug_branch_info.c | 2 +- xdebug_code_coverage.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xdebug_branch_info.c b/xdebug_branch_info.c index 45bb77c26..8e1cf0f62 100644 --- a/xdebug_branch_info.c +++ b/xdebug_branch_info.c @@ -141,7 +141,7 @@ static void xdebug_path_info_make_sure_level_exists(xdebug_path_info *path_info, orig_size = path_info->paths_size; - if (level > path_info->paths_size) { + if (level >= path_info->paths_size) { path_info->paths_size = level + 32; path_info->paths = realloc(path_info->paths, sizeof(xdebug_path*) * path_info->paths_size); diff --git a/xdebug_code_coverage.c b/xdebug_code_coverage.c index aba37cb85..344691c52 100644 --- a/xdebug_code_coverage.c +++ b/xdebug_code_coverage.c @@ -766,8 +766,8 @@ void xdebug_code_coverage_start_of_function(zend_op_array *op_array TSRMLS_DC) xdebug_prefill_code_coverage(op_array TSRMLS_CC); xdebug_path_info_add_path_for_level(XG(paths_stack), path, XG(level) TSRMLS_CC); - if (XG(branches).size == 0 || XG(level) > XG(branches).size) { - XG(branches).size += 32; + if (XG(branches).size == 0 || XG(level) >= XG(branches).size) { + XG(branches).size = XG(level) + 32; XG(branches).last_branch_nr = realloc(XG(branches).last_branch_nr, sizeof(int) * XG(branches.size)); }