https://bugs.kde.org/show_bug.cgi?id=439592

--- Comment #17 from Igor Kushnir <igor...@gmail.com> ---
(In reply to Eugene Shalygin from comment #12)
> Got back to this after some time. Seems like KDevelop's CMake parser can't
> handle strings with 0 bytes inside. Specifically, creating the CMake console
> project from the template and appending contents of
> Tests/RunCMake/Syntax/NullTerminatedArgument.cmake file from the CMake
> project to the CMakeLists.txt make KDevelop crash on it either during
> project loading or upon opening the file.
> 
> Valgrind says:
> ...
> ==800842==    by 0x3A15398F: fromLocal8Bit (qstring.h:710)
> ==800842==    by 0x3A15398F:
> CMakeListsParser::readCMakeFunction(cmListFileLexer_s*, CMakeFunctionDesc&)
> (cmakelistsparser.cpp:180)
> ==800842==    by 0x3A1540CE: CMakeListsParser::readCMakeFile(QString const&)
> (cmakelistsparser.cpp:126)
> ==800842==    by 0x3A1DEE17:
> CMakeParseJob::run(QSharedPointer<ThreadWeaver::JobInterface>,
> ThreadWeaver::Thread*) (cmakeparsejob.cpp:84)
The line in KDevelop code where the crash occurs (cmakelistsparser.cpp:180):
    func.arguments << CMakeFunctionArgument(
QString::fromLocal8Bit(token->text, token->length), false, token->line,
token->column );

token->text has type char*, that is a null-terminated string, which by
definition cannot contain null characters in the middle. The token comes from
cmListFileLexer_Scan(), which is located in
kdevelop/plugins/cmake/parser/cmListFileLexer.c. This file was copied from
CMake source code and modified. The cmListFileLexer_Token struct is still
returned from cmListFileLexer_Scan()
(https://gitlab.kitware.com/cmake/cmake/-/blob/master/Source/LexerParser/cmListFileLexer.c#L2788),
and this struct still contains char* text
(https://gitlab.kitware.com/cmake/cmake/-/blob/master/Source/cmListFileLexer.h#L28).
Perhaps this internal CMake library does not support null characters in source
files. Or KDevelop uses it incorrectly.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to