While reading through script_p2sh_tests.cpp I noticed one of the assertions in ValidateInputsStandardness checks the wrong transaction.
The test builds txToNonStd2_no_scriptSig (which spends a P2SH prevout with an empty scriptSig) and checks its standardness result ("input 0 P2SH redeemscript missing"), but the GetP2SHSigOpCount assertion right after it re-checks the previous transaction: line 433 is byte-identical to line 419. Looks like a copy-paste slip from 248c175e3d, which added a GetP2SHSigOpCount check after each constructed transaction.
This PR points the assertion at txToNonStd2_no_scriptSig and expects 0 sigops. With an empty scriptSig there's no redeemScript push, so GetSigOpCount(scriptSig) ends up counting an empty subscript and returns 0. This case wasn't asserted anywhere before. The line above covers the other side, where the same prevout spent with the actual redeemScript counts 20.
To make sure the fix isn't vacuous I also ran the assertion expecting 20, and it fails with [0 != 20].
Tested with:
cmake --build build --target test_bitcoin
build/bin/test_bitcoin --run_test=script_p2sh_tests