From d701fdd28b785345e9866892edc6be8d3daf0b84 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Sat, 25 Aug 2018 11:30:54 -0500 Subject: [PATCH] Add null check when creating Bktr --- hactoolnet/Program.cs | 1 - libhac/Bktr.cs | 4 ++-- libhac/Ticket.cs | 3 --- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/hactoolnet/Program.cs b/hactoolnet/Program.cs index 9f9b0661..c90d50ae 100644 --- a/hactoolnet/Program.cs +++ b/hactoolnet/Program.cs @@ -425,7 +425,6 @@ namespace hactoolnet using (var file = new FileStream(ctx.Options.InFile, FileMode.Open, FileAccess.Read)) { var save = new Savefile(file, ctx.Logger); - var layout = save.Header.Layout; if (ctx.Options.OutDir != null) { diff --git a/libhac/Bktr.cs b/libhac/Bktr.cs index 442cb35a..2dd722e0 100644 --- a/libhac/Bktr.cs +++ b/libhac/Bktr.cs @@ -20,9 +20,9 @@ namespace libhac public Bktr(Stream patchRomfs, Stream baseRomfs, NcaSection section) { if (section.Type != SectionType.Bktr) throw new ArgumentException("Section is not of type BKTR"); + Patch = patchRomfs ?? throw new NullReferenceException($"{nameof(patchRomfs)} cannot be null"); + Base = baseRomfs ?? throw new NullReferenceException($"{nameof(baseRomfs)} cannot be null"); - Patch = patchRomfs; - Base = baseRomfs; IvfcLevelHeader level5 = section.Header.Bktr.IvfcHeader.LevelHeaders[5]; Length = level5.LogicalOffset + level5.HashDataSize; diff --git a/libhac/Ticket.cs b/libhac/Ticket.cs index adc54f7b..125b1c73 100644 --- a/libhac/Ticket.cs +++ b/libhac/Ticket.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; namespace libhac {