From 555ac8bd15e17d52bbd04f78de71e03e131e7a48 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 11 Jun 2011 20:52:22 +0000 Subject: Fix potential use of uninitialized value git-svn-id: http://svn.drobilla.net/sord/trunk@150 3d64ff67-21c5-427c-a301-fe4f08042e5a --- src/sord.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/sord.c') diff --git a/src/sord.c b/src/sord.c index 1142b41..eafc99f 100644 --- a/src/sord.c +++ b/src/sord.c @@ -514,7 +514,7 @@ sord_best_index(SordModel* sord, const SordQuad pat, SearchMode* mode, int* n_pr + (pat[1] ? 1 : 0) * 0x010 + (pat[2] ? 1 : 0) * 0x001; - SordOrder good[2]; + SordOrder good[2] = { (SordOrder)-1, (SordOrder)-1 }; // Good orderings that don't require filtering *mode = RANGE; @@ -530,10 +530,12 @@ sord_best_index(SordModel* sord, const SordQuad pat, SearchMode* mode, int* n_pr case 0x111: *mode = SINGLE; return graph_search ? DEFAULT_GRAPH_ORDER : DEFAULT_ORDER; } - if (sord_has_index(sord, &good[0], n_prefix, graph_search)) { - return good[0]; - } else if (sord_has_index(sord, &good[1], n_prefix, graph_search)) { - return good[1]; + if (*mode == RANGE) { + if (sord_has_index(sord, &good[0], n_prefix, graph_search)) { + return good[0]; + } else if (sord_has_index(sord, &good[1], n_prefix, graph_search)) { + return good[1]; + } } // Not so good orderings that require filtering, but can -- cgit v1.2.1