cli_main: Fix freeing argv array
ISO C allows for argv contents to be modified by user code. Therefore we cannot depend on receiving back the same argv contents that were passed to user code. Otherwise it introduces a potential crash when freeing possibly nulled pointers.
Instead we introduce a GPtrArray auxiliary data structure to hold on to a private reference to the allocated memory.
Fix #20500 (closed)
(cherry picked from commit 4e065ece)
Co-authored-by: João Valverde j@v6e.pt