-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
highlight-issueHighlight native implementation issuesHighlight native implementation issues
Description
If the CodeGenerator::initTheme() is not called ahead of CodeGenerator::loadLanguage(), an unhandled std::out_of_range will be thrown by calling CodeGenerator::generate*() and will crash.
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 13) >= this->size() (which is 13)
This issue seems to occur with Highlight 4.0 or over.
Repro code
using Smdn.LibHighlightSharp.Bindings;
using var generator = CodeGenerator.getInstance(OutputType.HTML);
// Call CodeGenerator::loadLanguage before calling CodeGenerator::initTheme
generator.loadLanguage(pathToLangDefFile);
generator.initTheme(pathToThemeFile);
// This will throw std::out_of_range
Console.WriteLine(generator.generateString("using System;"));See full example.
Workaround
We must call CodeGenerator::initTheme() ahead of calling CodeGenerator::loadLanguage() and so on.
using Smdn.LibHighlightSharp.Bindings;
using var generator = CodeGenerator.getInstance(OutputType.HTML);
// Call CodeGenerator::initTheme ahead of calling CodeGenerator::loadLanguage and so on
generator.initTheme(pathToThemeFile);
generator.loadLanguage(pathToLangDefFile);
// This will not throw any exceptions
Console.WriteLine(generator.generateString("using System;"));Metadata
Metadata
Assignees
Labels
highlight-issueHighlight native implementation issuesHighlight native implementation issues