From cc580f9b7aa8beed79591c5af2c93ee5b7a9a18e Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Mon, 6 Jan 2014 20:08:18 +0000
Subject: [PATCH] [Fix] Clean up unidiffs when they fail to apply properly.

---
 dat/ship.xml  | 8 ++++----
 src/unidiff.c | 4 ++++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/dat/ship.xml b/dat/ship.xml
index 35d509e..cd669ab 100644
--- a/dat/ship.xml
+++ b/dat/ship.xml
@@ -26,17 +26,17 @@
    <crew>10</crew>
    <mass>95</mass>
    <fuel>1000000</fuel>
-   <cap_weapon>800</cap_weapon>
-   <cap_cargo>6000</cap_cargo>
+   <cap_weapon>80000</cap_weapon>
+   <cap_cargo>600000</cap_cargo>
   </characteristics>
   <outfits>
     <outfit quantity="1">Lancelot Fighter Bay</outfit>
-    <outfit quantity="2">Lancelot Fighter</outfit>
+    <outfit quantity="100">Lancelot Fighter</outfit>
     <outfit quantity="2">Ripper MK2</outfit>
     <outfit quantity="2">Ragnarok Beam</outfit>
     <outfit quantity="2">Orion Beam</outfit>
    <outfit quantity="1">Headhunter Launcher</outfit>
-   <outfit quantity="20">Headhunter</outfit>
+   <outfit quantity="100">Headhunter</outfit>
   </outfits>
  </ship>
  <ship name="Llama">
diff --git a/src/unidiff.c b/src/unidiff.c
index 1cbf7b4..47c1ecd 100644
--- a/src/unidiff.c
+++ b/src/unidiff.c
@@ -187,6 +187,10 @@ int diff_apply(char* name) {
     }
   } while(xml_nextNode(node));
 
+  /* More clean up. */
+  xmlFreeDoc(doc);
+  free(buf);
+
   WARN("UniDiff '%s' not found in "DIFF_DATA".", name);
   return -1;
 }