From 4a882e21d38624868dcccfd7b0909277a6e2ee73 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Wed, 13 Sep 2017 07:13:29 +0100 Subject: [PATCH] Don't update env_x/y if no points were read. Clang static analysis reports an 'Assigned value is garbage or undefined' for this. If no points were read from the file, the `n_points` variable is 0 and `env_x[n_points-1]` performs an out-of-bounds access. --- src/libespeak-ng/compiledata.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index d58a2262..f32754cf 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -1401,8 +1401,10 @@ static int LoadEnvelope2(FILE *f, const char *fname) n_points++; } } - env_x[n_points] = env_x[n_points-1]; - env_y[n_points] = env_y[n_points-1]; + if (n_points > 0) { + env_x[n_points] = env_x[n_points-1]; + env_y[n_points] = env_y[n_points-1]; + } ix = -1; ix2 = 0;