Browse Source

fix a unasigned memory problem in the fuzzer

Julius Pfrommer 7 years ago
parent
commit
9313d4ee0d
1 changed files with 4 additions and 3 deletions
  1. 4 3
      tests/fuzz/fuzz_binary_message.cc

+ 4 - 3
tests/fuzz/fuzz_binary_message.cc

@@ -12,9 +12,9 @@
 ** Main entry point.  The fuzzer invokes this function with each
 ** fuzzed input.
 */
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
-
-    UA_ByteString sentData;
+extern "C" int
+LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+    UA_ByteString sentData = UA_BYTESTRING_NULL;
     UA_Connection c = createDummyConnection(&sentData);
     UA_ServerConfig *config = UA_ServerConfig_new_default();
     UA_Server *server = UA_Server_new(config);
@@ -32,6 +32,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
 	UA_Server_run_shutdown(server);
     UA_Server_delete(server);
     UA_ServerConfig_delete(config);
+    c.close(&c);
     UA_Connection_deleteMembers(&c);
     return 0;
 }