Skip to content

Commit 931cc76

Browse files
thestr4ng3rPrince781
authored andcommitted
ccproject: fix segfault with empty command
Don't analyze a compile command with an empty (null) "command" Closes #163
1 parent 61ae142 commit 931cc76

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/projects/ccproject.vala

+6-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ class Vls.CcProject : Project {
6262
if (cc == null)
6363
throw new ProjectError.INTROSPECTION (@"JSON node is null. Bailing out!");
6464

65-
if (cc.command.length > 0 && cc.command[0].contains ("valac"))
65+
if (cc.command.length == 0) {
66+
warning ("CC#%d has empty command list", i);
67+
continue;
68+
}
69+
70+
if (cc.command[0].contains ("valac"))
6671
build_targets.add (new Compilation (cc.directory, cc.file ?? @"CC#$i", @"CC#$i", i,
6772
cc.command[0:1], cc.command[1:cc.command.length],
6873
new string[]{}, new string[]{}));

src/projects/types.vala

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ namespace Vls {
5454
val = Value (typeof (string[]));
5555
string[] command_array = {};
5656
try {
57-
command_array = Util.get_arguments_from_command_str (property_node.get_string ());
57+
string? command_str = property_node.get_string ();
58+
if (command_str != null)
59+
command_array = Util.get_arguments_from_command_str (property_node.get_string ());
5860
} catch (RegexError e) {
5961
warning ("failed to parse `%s': %s", property_node.get_string (), e.message);
6062
}

0 commit comments

Comments
 (0)