Free up memory from file menu pointers

* Cleanup sub-filemenu pointers after their results are copied.
* Cleanup file pointers after all operations have been performed on
the file.

Change-Id: Ie6c482c5ffddd7ebebdc99bbe8ae856e53e1405f
(cherry picked from commit 5360b52dba6b120b6e0ba5c775e2a961504a34a3)
Do not modify original items pointer when filtering NULL entries

get_filtered_menu_selection currently modifies the items menu passed
to it. This can be problematic if the items menu is needed later without
any filtering of NULL entries. Instead, let's modify a copy of the items
menu, leaving the original intact.

Change-Id: Ief6f538441ea78fcd8eba3a815354f06bda849a0
Merge remote-tracking branch 'cm/cm-11.0' into cm-11.0