Skip to content

Commit

Permalink
Fix memory leak in _command_line in Main.vala
Browse files Browse the repository at this point in the history
  • Loading branch information
JMoerman committed Oct 20, 2017
1 parent 1507478 commit e0b2bd3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,15 @@ class Main : Gtk.Application {
context.add_group (Gtk.get_option_group (true));

string[] args = command_line.get_arguments ();
// Copy the pointers of the strings to a new array so references to the
// strings in args are not lost when context.parse is called
string*[] _args = new string*[args.length];
for (int i = 0; i < args.length; i++) {
_args[i] = args[i];
}

try {
unowned string[] tmp = args;
unowned string[] tmp = _args;
context.parse (ref tmp);
} catch (Error e) {
stdout.printf ("%s: Error: %s \n", GOFI.APP_NAME, e.message);
Expand Down

0 comments on commit e0b2bd3

Please sign in to comment.