From: Eric Leblond Date: Wed, 21 Oct 2015 12:56:38 +0000 (+0200) Subject: json-file: avoid allocation X-Git-Tag: suricata-3.0RC1~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1704%2Fhead;p=thirdparty%2Fsuricata.git json-file: avoid allocation --- 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;