Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Thu, 19 Oct 2023 12:24:55 UTC Commit: f1723b3bdd194c3a2dbec293c05a0835ff20d521 https://github.com/geany/geany/commit/f1723b3bdd194c3a2dbec293c05a0835ff20d5...
Log Message: ----------- Fix crash setting an invalid lexer ID
`LexerNameFromID()` will return `NULL` for unknown IDs, and `CreateLexer()` does not gracefully handle it, so we need to check this on our end.
Part of #3615.
Modified Paths: -------------- src/sciwrappers.c
Modified: src/sciwrappers.c 9 lines changed, 8 insertions(+), 1 deletions(-) =================================================================== @@ -701,7 +701,14 @@ void sci_set_lexer(ScintillaObject *sci, guint lexer_id) gint old = sci_get_lexer(sci);
/* TODO, LexerNameFromID() is already deprecated */ - ILexer5 *lexer = CreateLexer(LexerNameFromID(lexer_id)); + const char *lexer_name = LexerNameFromID(lexer_id); + if (! lexer_name) + { + g_warning("Failed to find lexer for ID %u", lexer_id); + return; + } + + ILexer5 *lexer = CreateLexer(lexer_name);
SSM(sci, SCI_SETILEXER, 0, (uintptr_t) lexer);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).