Fix small memory leak in legacy plugin code