Index: /trunk/configure.ac
===================================================================
--- /trunk/configure.ac	(revision 458)
+++ /trunk/configure.ac	(revision 459)
@@ -1646,4 +1646,5 @@
                 mydebugit="yes"
 	elif test "x${enable_debug}" = "xgdb"; then
+	     	AC_DEFINE(SH_ABORT_ON_ERROR, 1, [Use abort])
                 if test "x${myneedg3}" = "xyes"; then
                         mydebugdef="-g3"
Index: /trunk/docs/Changelog
===================================================================
--- /trunk/docs/Changelog	(revision 458)
+++ /trunk/docs/Changelog	(revision 459)
@@ -12,6 +12,7 @@
 	* Fixed incorrect logic in setting the ALLIGNORE flag (more specific
 	  directory / file directives were ignored)
-	* Fix for tickets #358 (repetitive lstat warning about deleted 
+	* Fix for tickets #358 (repetitive lstat warning about deleted
 	  directory) and #359 (reporting of deleted/added top level directory)
+	* Fix a free() on NULL (harmless but avoids spurious warning)
 
 3.1.1 (01-0-2014):
Index: /trunk/include/samhain.h
===================================================================
--- /trunk/include/samhain.h	(revision 458)
+++ /trunk/include/samhain.h	(revision 459)
@@ -414,4 +414,10 @@
  **************************************************/
 
+#if defined(SH_ABORT_ON_ERROR)
+#define SH_ABORT abort()
+#else
+#define SH_ABORT 
+#endif
+
 #if defined(__GNUC__) && (__GNUC__ >= 4)
 #define SH_GNUC_SENTINEL __attribute__((__sentinel__))
Index: /trunk/src/sh_err_log.c
===================================================================
--- /trunk/src/sh_err_log.c	(revision 458)
+++ /trunk/src/sh_err_log.c	(revision 459)
@@ -598,5 +598,6 @@
         (*service_failure) = 1;
       }
-      SH_FREE(tmp);
+      if (tmp)
+	SH_FREE(tmp);
       SL_RETURN(-1, _("sh_log_open"));
     }
Index: /trunk/src/sh_mem.c
===================================================================
--- /trunk/src/sh_mem.c	(revision 458)
+++ /trunk/src/sh_mem.c	(revision 459)
@@ -444,4 +444,5 @@
     {
       sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MNULL);
+      SH_ABORT;
     }
   SL_RET0(_("sh_mem_free"));
@@ -466,4 +467,5 @@
       /* use _exit() rather than exit() - we malloc() in atexit()  
        */
+      SH_ABORT;
       _exit (EXIT_FAILURE);
     }
