From f33390a5100aa3408bf82066b3fe30e000642560 Mon Sep 17 00:00:00 2001
From: "Sven M. Hallberg" <pesco@khjk.org>
Date: Sun, 12 May 2013 01:27:19 +0200
Subject: [PATCH] fix memory issues in benchmark.c

---
 src/benchmark.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/benchmark.c b/src/benchmark.c
index 5c92706..d81d2f8 100644
--- a/src/benchmark.c
+++ b/src/benchmark.c
@@ -30,7 +30,7 @@ HBenchmarkResults *h_benchmark__m(HAllocator* mm__, HParser* parser, HParserTest
   HParserTestcase* tc = testcases;
   HParserBackend backend = PB_MIN;
   HBenchmarkResults *ret = h_new(HBenchmarkResults, 1);
-  ret->len = PB_MAX-PB_MIN;
+  ret->len = PB_MAX-PB_MIN+1;
   ret->results = h_new(HBackendResults, ret->len);
 
   for (backend = PB_MIN; backend <= PB_MAX; backend++) {
@@ -108,6 +108,8 @@ void h_benchmark_report(FILE* stream, HBenchmarkResults* result) {
   for (size_t i=0; i<result->len; ++i) {
     fprintf(stream, "Backend %ld ... \n", i);
     for (size_t j=0; j<result->results[i].n_testcases; ++j) {
+      if(result->results[i].cases == NULL)
+        continue;
       fprintf(stream, "Case %ld: %ld ns/parse\n", j,  result->results[i].cases[j].parse_time);
     }
   }
-- 
GitLab