Fix potential memory leak in LibraryInjector.