fix a potential memory leak in worker