Skip to content

Commit 9b022f2

Browse files
committed
Add type checks in Proton.find_proton_versions (tkashkin#292, tkashkin#101)
1 parent d1df472 commit 9b022f2

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/data/compat/Proton.vala

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,16 +267,24 @@ namespace GameHub.Data.Compat
267267
if(app_node != null && app_node is BinaryVDF.ListNode)
268268
{
269269
var app = (BinaryVDF.ListNode) app_node;
270-
var common = (BinaryVDF.ListNode) app.get_nested({"appinfo", "common"});
270+
var common_node = app.get_nested({"appinfo", "common"});
271271

272-
if(common != null)
272+
if(common_node != null && common_node is BinaryVDF.ListNode)
273273
{
274-
var name = ((BinaryVDF.StringNode) common.get("name")).value;
275-
var type = ((BinaryVDF.StringNode) common.get("type")).value;
274+
var common = (BinaryVDF.ListNode) common_node;
276275

277-
if(type.down() == "tool" && name.down().has_prefix("proton "))
276+
var name_node = common.get("name");
277+
var type_node = common.get("type");
278+
279+
if(name_node != null && name_node is BinaryVDF.StringNode && type_node != null && type_node is BinaryVDF.StringNode)
278280
{
279-
versions.add(new Proton(app.key, name));
281+
var name = ((BinaryVDF.StringNode) name_node).value;
282+
var type = ((BinaryVDF.StringNode) type_node).value;
283+
284+
if(type != null && type.down() == "tool" && name != null && name.down().has_prefix("proton "))
285+
{
286+
versions.add(new Proton(app.key, name));
287+
}
280288
}
281289
}
282290
}

0 commit comments

Comments
 (0)