[FL-3188] Fix crash when emulating a DSGeneric key (#2530)

This commit is contained in:
Georgii Surkov 2023-03-24 03:26:43 +03:00 committed by GitHub
parent 9a14699aa0
commit fad24efdf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,6 +62,7 @@ bool ds_generic_write_blank(OneWireHost* host, iButtonProtocolData* protocol_dat
} }
static bool ds_generic_reset_callback(bool is_short, void* context) { static bool ds_generic_reset_callback(bool is_short, void* context) {
furi_assert(context);
DallasGenericProtocolData* data = context; DallasGenericProtocolData* data = context;
if(!is_short) { if(!is_short) {
onewire_slave_set_overdrive(data->state.bus, is_short); onewire_slave_set_overdrive(data->state.bus, is_short);
@ -93,7 +94,7 @@ void ds_generic_emulate(OneWireSlave* bus, iButtonProtocolData* protocol_data) {
DallasGenericProtocolData* data = protocol_data; DallasGenericProtocolData* data = protocol_data;
data->state.bus = bus; data->state.bus = bus;
onewire_slave_set_reset_callback(bus, ds_generic_reset_callback, NULL); onewire_slave_set_reset_callback(bus, ds_generic_reset_callback, protocol_data);
onewire_slave_set_command_callback(bus, ds_generic_command_callback, protocol_data); onewire_slave_set_command_callback(bus, ds_generic_command_callback, protocol_data);
} }