Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: GitHub noreply@github.com Date: Mon, 27 May 2024 15:18:41 UTC Commit: ac357ed1c84d07a4e19d2dbb00251eaec6500e3c https://github.com/geany/geany/commit/ac357ed1c84d07a4e19d2dbb00251eaec6500e...
Log Message: ----------- Merge pull request #3865 from techee/none_crash
Fix crash by protecting tm_ctags_*() functions against TM_PARSER_NONE
Modified Paths: -------------- src/tagmanager/tm_ctags.c
Modified: src/tagmanager/tm_ctags.c 25 lines changed, 22 insertions(+), 3 deletions(-) =================================================================== @@ -444,6 +444,9 @@ void tm_ctags_parse(guchar *buffer, gsize buffer_size, { g_return_if_fail(buffer != NULL || file_name != NULL);
+ if (language == TM_PARSER_NONE) + return; + parseRawBuffer(file_name, buffer, buffer_size, language, source_file);
rename_anon_tags(source_file); @@ -452,6 +455,9 @@ void tm_ctags_parse(guchar *buffer, gsize buffer_size,
const gchar *tm_ctags_get_lang_name(TMParserType lang) { + if (lang == TM_PARSER_NONE) + return "unknown"; + return getLanguageName(lang); }
@@ -464,10 +470,15 @@ TMParserType tm_ctags_get_named_lang(const gchar *name)
const gchar *tm_ctags_get_lang_kinds(TMParserType lang) { - guint kind_num = countLanguageKinds(lang); static gchar kinds[257]; + guint kind_num; guint i;
+ if (lang == TM_PARSER_NONE) + return ""; + + kind_num = countLanguageKinds(lang); + for (i = 0; i < kind_num; i++) kinds[i] = getLanguageKind(lang, i)->letter; kinds[i] = '\0'; @@ -478,14 +489,22 @@ const gchar *tm_ctags_get_lang_kinds(TMParserType lang)
const gchar *tm_ctags_get_kind_name(gchar kind, TMParserType lang) { - kindDefinition *def = getLanguageKindForLetter(lang, kind); + kindDefinition *def = NULL; + + if (lang != TM_PARSER_NONE) + def = getLanguageKindForLetter(lang, kind); + return def ? def->name : "unknown"; }
gchar tm_ctags_get_kind_from_name(const gchar *name, TMParserType lang) { - kindDefinition *def = getLanguageKindForName(lang, name); + kindDefinition *def = NULL; + + if (lang != TM_PARSER_NONE) + def = getLanguageKindForName(lang, name); + return def ? def->letter : '-'; }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).