rgui: Fix potential memory leak