CMake: Prevent qt_remove_args() from accessing out-of-range list index

Pick-to: 6.1
Change-Id: Ie9c5f0551722c7d3fb11879b209c11ce3d7ccd6d
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
This commit is contained in:
Craig Scott 2021-02-24 18:45:25 +11:00
parent 8daa944313
commit 10b3681c72

View File

@ -131,6 +131,10 @@ function(qt_remove_args out_var)
# remove arg # remove arg
list(REMOVE_AT result ${find_result}) list(REMOVE_AT result ${find_result})
list(LENGTH result result_len) list(LENGTH result result_len)
if(find_result EQUAL result_len)
# We removed the last argument, could have been an option keyword
continue()
endif()
list(GET result ${find_result} arg_current) list(GET result ${find_result} arg_current)
# remove values until we hit another arg or the end of the list # remove values until we hit another arg or the end of the list
while(NOT ${arg_current} IN_LIST arg_ALL_ARGS AND find_result LESS result_len) while(NOT ${arg_current} IN_LIST arg_ALL_ARGS AND find_result LESS result_len)