From 820e4e531ddc59c98ed71b935e0e78724b651a9c Mon Sep 17 00:00:00 2001 From: David van der Spoel Date: Thu, 12 Jun 2014 09:58:11 +0200 Subject: [PATCH] Fix memory-usage error in g_chi Out of array bounds writing error as pointed out by valgrind is fixed by this patch, preventing a SEGV. Fixes #1503 Change-Id: I57959f4751f3eb645ff66bbcd4418607af56c1a4 --- src/tools/anadih.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/anadih.c b/src/tools/anadih.c index 5f5da0eefb..1c0e9000dd 100644 --- a/src/tools/anadih.c +++ b/src/tools/anadih.c @@ -417,7 +417,8 @@ void mk_chi_lookup (int **lookup, int maxchi, real **dih, int i, j, Dih, Chi; j = 0; - for (Dih = 0; (Dih < NONCHI+maxchi); Dih++) + /* NONCHI points to chi1, therefore we have to start counting there. */ + for (Dih = NONCHI; (Dih < NONCHI+maxchi); Dih++) { for (i = 0; (i < nlist); i++) { -- 2.22.0