core: fix memory leak in evaluation of expression when a logical operator ("&&" or "||") is found