Tripartite entanglement in qudit stabilizer states and application in quantum error correction