fix: memory leak in parsing function