Fix memory leak for setStore