mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-17 15:32:10 +08:00
Fix allocation in CROSSCOMPILING_EMULATOR evaluation
In commit fec441ec17
(Teach CROSSCOMPILING_EMULATOR to support
arguments, 2019-05-30, v3.15.0-rc1~6^2) the new member
`cmCustomCommandGenerator::EmulatorsWithArguments` was not initialized
to the proper size. Fix this and add a test case covering the crash
that could occur with multiple commands where an emulator appears only
in a later command.
Fixes: #19500
Co-Author: Brad King <brad.king@kitware.com>
This commit is contained in:

committed by
Brad King

parent
79bcf4e165
commit
bf6f5467a0
@@ -25,6 +25,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
|
|||||||
, OldStyle(cc.GetEscapeOldStyle())
|
, OldStyle(cc.GetEscapeOldStyle())
|
||||||
, MakeVars(cc.GetEscapeAllowMakeVars())
|
, MakeVars(cc.GetEscapeAllowMakeVars())
|
||||||
, GE(new cmGeneratorExpression(cc.GetBacktrace()))
|
, GE(new cmGeneratorExpression(cc.GetBacktrace()))
|
||||||
|
, EmulatorsWithArguments(cc.GetCommandLines().size())
|
||||||
{
|
{
|
||||||
const cmCustomCommandLines& cmdlines = this->CC.GetCommandLines();
|
const cmCustomCommandLines& cmdlines = this->CC.GetCommandLines();
|
||||||
for (cmCustomCommandLine const& cmdline : cmdlines) {
|
for (cmCustomCommandLine const& cmdline : cmdlines) {
|
||||||
@@ -107,7 +108,6 @@ void cmCustomCommandGenerator::FillEmulatorsWithArguments()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->EmulatorsWithArguments.emplace_back();
|
|
||||||
cmSystemTools::ExpandListArgument(emulator_property,
|
cmSystemTools::ExpandListArgument(emulator_property,
|
||||||
this->EmulatorsWithArguments[c]);
|
this->EmulatorsWithArguments[c]);
|
||||||
}
|
}
|
||||||
|
@@ -26,12 +26,14 @@ add_custom_command(OUTPUT output2
|
|||||||
|
|
||||||
# DoesNotUseEmulator: The command will fail if emulator is prepended
|
# DoesNotUseEmulator: The command will fail if emulator is prepended
|
||||||
add_custom_command(OUTPUT output3
|
add_custom_command(OUTPUT output3
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo generated_exe_emulator_unexpected
|
||||||
COMMAND $<TARGET_FILE:generated_exe_emulator_unexpected>
|
COMMAND $<TARGET_FILE:generated_exe_emulator_unexpected>
|
||||||
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3
|
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3
|
||||||
DEPENDS generated_exe_emulator_unexpected)
|
DEPENDS generated_exe_emulator_unexpected)
|
||||||
|
|
||||||
# DoesNotUseEmulator: The command will fail if emulator is prepended
|
# DoesNotUseEmulator: The command will fail if emulator is prepended
|
||||||
add_custom_command(OUTPUT outputImp
|
add_custom_command(OUTPUT outputImp
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo generated_exe_emulator_unexpected_imported
|
||||||
COMMAND generated_exe_emulator_unexpected_imported
|
COMMAND generated_exe_emulator_unexpected_imported
|
||||||
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/outputImp
|
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/outputImp
|
||||||
)
|
)
|
||||||
@@ -39,6 +41,7 @@ add_custom_command(OUTPUT outputImp
|
|||||||
# UsesEmulator: The command only succeeds if the emulator is prepended
|
# UsesEmulator: The command only succeeds if the emulator is prepended
|
||||||
# to the command.
|
# to the command.
|
||||||
add_custom_command(OUTPUT output4
|
add_custom_command(OUTPUT output4
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo generated_exe_emulator_expected
|
||||||
COMMAND generated_exe_emulator_expected
|
COMMAND generated_exe_emulator_expected
|
||||||
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output4
|
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output4
|
||||||
DEPENDS generated_exe_emulator_expected)
|
DEPENDS generated_exe_emulator_expected)
|
||||||
|
Reference in New Issue
Block a user