sort_patches() can reallocate the patch list array.
So after main_window is called (which calls sort_patches())
the patchs array might have changed. We current call
plist_free() on the old patch list, which can crash.
So instead, call sort_patches() before calling main_window(),
then call plist_free() afterwards, on the patch list
that sort_patches() returned.
This avoids the crash.