From 3ba58ccdefeaba41274ee6182a7fcf4a84c543a8 Mon Sep 17 00:00:00 2001
From: Brian Carrier <carrier@sleuthkit.org>
Date: Thu, 17 Dec 2015 11:06:12 -0500
Subject: [PATCH] Ensure mac partition tables have at least one valid partition

---
 tsk/vs/mac.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tsk/vs/mac.c b/tsk/vs/mac.c
index bde5ba152..e609ce8b7 100644
--- a/tsk/vs/mac.c
+++ b/tsk/vs/mac.c
@@ -148,11 +148,17 @@ mac_load_table(TSK_VS_INFO * vs)
         if (NULL == tsk_vs_part_add(vs, (TSK_DADDR_T) part_start,
                 (TSK_DADDR_T) part_size, (TSK_VS_PART_FLAG_ENUM)flag, str, -1,
                 idx))
+            free(part_buf);
             return 1;
     }
     free(part_buf);
     part_buf = NULL;
 
+    // Bail if we did find any valid entries
+    if (vs->part_count == 0) {
+        return 1;
+    }
+
     /* Add an entry for the table length */
     if ((table_str = tsk_malloc(16)) == NULL) {
         return 1;
-- 
GitLab