CMake/Tests/RunCMake/if/MatchesSelf.cmake
Brad King 6ffc432367 cmConditionEvaluator: Fix matching of CMAKE_MATCH_* values (#15944)
While evaluating `if(MATCHES)` we get a `const char*` pointer to the
string to be matched.  On code like

    if(CMAKE_MATCH_COUNT MATCHES "Y")

the string to be matched may be owned by our own result variables.
We must move the value to our own buffer before clearing them.
Otherwise we risk reading freed storage.
2016-02-01 10:05:10 -05:00

5 lines
95 B
CMake

foreach(n 0 1 2 3 4 5 6 7 8 9 COUNT)
if(CMAKE_MATCH_${n} MATCHES "x")
endif()
endforeach()