To delete the signature from scriptSig, OP_CHECKSIG constructs a new CScript object from the signature found on the stack and then looks for an exact copy of this object in scriptSig.
However, if the original signature was pushed using OP_PUSHDATA and the signature is short enough to be pushed using one of the 1-75 opcodes, the two objects will not match and the signature verification will fail even though the values are the same.
This patch fixes this by comparing the data-pushing opcode's payload only (excluding the opcode itself).
I've tested this with valid testnet transactions, which are verified correctly.
As this is my first bitcoin patch and it touches a rather sensitive part of the code, please review/test it for yourselves as well!