Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Wed, 20 Nov 2013 17:40:22 UTC Commit: 10893c4ada3be907a97dd4e472de029442e687bc https://github.com/geany/geany/commit/10893c4ada3be907a97dd4e472de029442e687...
Log Message: ----------- R: fix invalid memory access in the tag parser
Modified Paths: -------------- tagmanager/ctags/r.c
Modified: tagmanager/ctags/r.c 24 files changed, 17 insertions(+), 7 deletions(-) =================================================================== @@ -27,9 +27,17 @@ ch++
#ifndef R_REGEX -static kindOption RKinds [] = { +typedef enum { + K_FUNCTION, + K_LIBRARY, + K_SOURCE, + KIND_COUNT +} rKind; + +static kindOption RKinds [KIND_COUNT] = { { TRUE, 'f', "function", "functions" }, - { TRUE, 's', "other", "libraries" } + { TRUE, 's', "other", "libraries" }, + { TRUE, 's', "other", "sources" }, }; #endif
@@ -48,18 +56,20 @@ static void installRRegex (const langType language) "^[ \t]*(library|source|load|data)[\(]([a-zA-Z0-9_]+)[\)]", "\2", "s,other", NULL); } #else -static void makeRTag(const vString* const name, int kind) +static void makeRTag(const vString* const name, rKind kind) { tagEntryInfo e; initTagEntry(&e, vStringValue(name));
+ Assert(kind >= 0 && kind < KIND_COUNT); + e.kindName = RKinds[kind].name; e.kind = RKinds[kind].letter;
makeTagEntry(&e); }
-extern void createRTags(void) +static void createRTags(void) { vString *vLine = vStringNew(); vString *name = vStringNew(); @@ -82,7 +92,7 @@ extern void createRTags(void) cp += 7; SKIPSPACE(cp); if (*cp == '(') - ikind = 1; + ikind = K_LIBRARY; else cp -= 7; } else if (strncasecmp((const char*)cp, "source", (size_t)6) == 0) { @@ -90,7 +100,7 @@ extern void createRTags(void) cp += 6; SKIPSPACE(cp); if (*cp == '(') - ikind = 2; + ikind = K_SOURCE; else cp -= 6; } @@ -145,7 +155,7 @@ extern void createRTags(void) vStringTerminate(name); /* if the string really exists, make a tag of it */ if (vStringLength(name) > 0) - makeRTag(name, 0); + makeRTag(name, K_FUNCTION);
/* prepare for the next iteration */ vStringClear(name);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).