]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http-json: add missing cleanup functions
authorVictor Julien <victor@inliniac.net>
Thu, 10 Apr 2014 06:35:51 +0000 (08:35 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 10 Apr 2014 06:35:51 +0000 (08:35 +0200)
Add cleanup functions.

src/output-json-http.c

index 7aca281fdeaaaecd622526196f0e995ab98c29b0..e2d5270cdfcca41e4b98d2c8e476f7d28052ba4d 100644 (file)
@@ -232,6 +232,15 @@ static int JsonHttpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Fl
     SCReturnInt(TM_ECODE_OK);
 }
 
+static void OutputHttpLogDeinit(OutputCtx *output_ctx)
+{
+    LogHttpFileCtx *http_ctx = output_ctx->data;
+    LogFileCtx *logfile_ctx = http_ctx->file_ctx;
+    LogFileFreeCtx(logfile_ctx);
+    SCFree(http_ctx);
+    SCFree(output_ctx);
+}
+
 #define DEFAULT_LOG_FILENAME "http.json"
 OutputCtx *OutputHttpLogInit(ConfNode *conf)
 {
@@ -272,7 +281,7 @@ OutputCtx *OutputHttpLogInit(ConfNode *conf)
         }
     }
     output_ctx->data = http_ctx;
-    output_ctx->DeInit = NULL;
+    output_ctx->DeInit = OutputHttpLogDeinit;
 
     /* enable the logger for the app layer */
     AppLayerParserRegisterLogger(IPPROTO_TCP, ALPROTO_HTTP);
@@ -280,6 +289,13 @@ OutputCtx *OutputHttpLogInit(ConfNode *conf)
     return output_ctx;
 }
 
+static void OutputHttpLogDeinitSub(OutputCtx *output_ctx)
+{
+    LogHttpFileCtx *http_ctx = output_ctx->data;
+    SCFree(http_ctx);
+    SCFree(output_ctx);
+}
+
 OutputCtx *OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
 {
     AlertJsonThread *ajt = parent_ctx->data;
@@ -307,7 +323,7 @@ OutputCtx *OutputHttpLogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
         }
     }
     output_ctx->data = http_ctx;
-    output_ctx->DeInit = NULL;
+    output_ctx->DeInit = OutputHttpLogDeinitSub;
 
     /* enable the logger for the app layer */
     AppLayerParserRegisterLogger(IPPROTO_TCP, ALPROTO_HTTP);