Fix a memory leak on invalid expression