From 16b210f1ea500193d942955eec2572fe6e2df46a Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Wed, 21 Oct 2015 14:56:38 +0200 Subject: [PATCH] json-file: avoid allocation --- src/output-json-file.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/output-json-file.c b/src/output-json-file.c index f2f21df34b..9506a74670 100644 --- a/src/output-json-file.c +++ b/src/output-json-file.c @@ -128,14 +128,11 @@ static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p, const F if (ff->flags & FILE_MD5) { size_t x; int i; - char *s = SCMalloc(256); - if (likely(s != NULL)) { - for (i = 0, x = 0; x < sizeof(ff->md5); x++) { - i += snprintf(&s[i], 255-i, "%02x", ff->md5[x]); - } - json_object_set_new(fjs, "md5", json_string(s)); - SCFree(s); + char s[256]; + for (i = 0, x = 0; x < sizeof(ff->md5); x++) { + i += snprintf(&s[i], 255-i, "%02x", ff->md5[x]); } + json_object_set_new(fjs, "md5", json_string(s)); } #endif break; -- 2.47.2