]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
json-file: avoid allocation 1704/head
authorEric Leblond <eric@regit.org>
Wed, 21 Oct 2015 12:56:38 +0000 (14:56 +0200)
committerEric Leblond <eric@regit.org>
Wed, 21 Oct 2015 15:05:41 +0000 (17:05 +0200)
src/output-json-file.c

index f2f21df34bde6afc763958cd23272185048de40c..9506a74670dc07c64906730e9623c17394bdebf9 100644 (file)
@@ -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;