test/fuzz: fix memory in l2cap fuzzer

This commit is contained in:
Matthias Ringwald 2024-01-04 19:20:51 +01:00
parent 68894c7457
commit e3ea12006b

View File

@ -213,11 +213,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
static int initialized = 0;
if (initialized == 0){
initialized = 1;
btstack_memory_init();
btstack_run_loop_init(btstack_run_loop_posix_get_instance());
hci_connection.con_handle = 0x0000;
}
btstack_memory_init();
// prepare test data
if (size < 5) return 0;
uint8_t packet_type = (data[0] & 1) ? HCI_EVENT_PACKET : HCI_ACL_DATA_PACKET;
@ -287,5 +288,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
// teardown
l2cap_free_channels_fuzz();
btstack_memory_deinit();
return 0;
}