diff --git a/src/sandbox.c b/src/sandbox.c
index 4252784..f4d1c97 100755
--- a/src/sandbox.c
+++ b/src/sandbox.c
@@ -3,7 +3,6 @@
 #include "utils.h"
 #include "backing.h"
 #include "container.h"
-#include "domain.h"
 
 #include <stdio.h>
 #include <stdbool.h>
diff --git a/src/xml.c b/src/xml.c
index a8553e7..031ce52 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -5,6 +5,8 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
 
 result_t generate_domain_xml(char** _xml, const char* container, uint64_t memory, int vcpus, const char** pci_addresses, const char** iso_paths, int vnc_port, const char* vnc_password) {
 	// Initialize the output parameters
@@ -132,7 +134,14 @@ result_t generate_pci_xml(char** _xml, const char** pci_addresses) {
 		return result;
 
 	// Generate the XML configuration for the PCI devices
+	errno = 0;
 	char* xml = strdup("");
+	if (xml == NULL) {
+		for (int i = 0; pci_devices[i] != NULL; i++)
+			free(pci_devices[i]);
+		free(pci_devices);
+		return failure("Failed to allocate memory for the initial XML configuration (%s).", strerror(errno));
+	}
 
 	// For each PCI device, generate the XML configuration, and append it to the result
 	for (int i = 0; pci_devices[i] != NULL; i++) {
@@ -195,7 +204,10 @@ result_t generate_iso_xml(char** _xml, const char** iso_paths) {
 	*_xml = NULL;
 
 	// Generate the XML configuration for the ISO images
+	errno = 0;
 	char* xml = strdup("");
+	if (xml == NULL)
+		return failure("Failed to allocate memory for the initial XML configuration (%s).", strerror(errno));
 
 	// For each ISO image, generate the XML configuration, and append it to the result
 	for (int i = 0; iso_paths[i] != NULL; i++) {