aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2014-11-14 20:44:20 +0100
committerEliseo Martínez <eliseomarmol@gmail.com>2014-11-18 21:57:47 +0100
commit04e42f2ae409294d551c9b589aee4cbfd2616d68 (patch)
treeb815cb86e7b165ce5e9685d1467d85f1a8f3c99f
parent9e37c1d3b6b9d0d35d7f7558d3efb555757278c0 (diff)
downloadrneovim-04e42f2ae409294d551c9b589aee4cbfd2616d68.tar.gz
rneovim-04e42f2ae409294d551c9b589aee4cbfd2616d68.tar.bz2
rneovim-04e42f2ae409294d551c9b589aee4cbfd2616d68.zip
Fix warnings: tag.c: test_for_static()/get_tags(): Various (2): FP.
Problems : Assigned value is garbage or undefined @ 2191. Uninitialized argument value @ 2796. Diagnostic : False positives. Rationale : Both problems share the same cause. Error happens in get_tags(), if parse_match() fails because of parse_tag_line() failing before. Then, `tp` is not correctly initialized and subsequent code accesses garbage values. This is not really possible, as parse_tag_line() should not fail after find_tags() has been successful. That is because find_tags() already does tag line parsing, using parse_tag_line() itself for it (or a quicker alternative that should produce same result). That's why return value of parse_match() is ignored, and subsequent code assumes it is successful. Resolution : Assert parse_match() always successful.
-rw-r--r--src/nvim/tag.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index e267280bbd..816e9902fe 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -10,6 +10,7 @@
* Code to handle tags and the tag stack
*/
+#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
@@ -2779,7 +2780,8 @@ int get_tags(list_T *list, char_u *pat)
TAG_REGEXP | TAG_NOIC, (int)MAXCOL, NULL);
if (ret == OK && num_matches > 0) {
for (i = 0; i < num_matches; ++i) {
- parse_match(matches[i], &tp);
+ int parse_result = parse_match(matches[i], &tp);
+ assert(parse_result == OK);
is_static = test_for_static(&tp);
/* Skip pseudo-tag lines. */