Misledgering possibility for double spending attack Imagine a malminer with two important abilities: having enough hashrate for producing blocks in a single-miner mode in reasonable amount of time and having a malconfigured miner software which doing somewhat a usual mining job, but forces some malminer's coins to be spend twice instead of processing only first transaction. What will next miner do if he will get the misledgered block with all others conditions satisfying (correct coin owner's signature, enough proof-of-bruteforse zeroes in checksum, 6 trailing blocks without double-spending, etc)? If the attack is not possible, I want to look at the code behind such a protection.
If a block contains an invalid transaction, it will be rejected by all honest full nodes. Full nodes verify transactions in a block in linear order, so after the first transaction is encountered, the nodes will deem the UTXOs being used as spent. Then when the second transaction (the double spend) is encountered, the nodes will see it as trying to spend already-spent outputs, and reject it along with the block.