Merge "Fix the potential memory leak issue caused by setExtension." into main