espressif: i2c: initialize "has_lock"

Otherwise, a stack-constructed i2c instance might get some other value
here.
This commit is contained in:
Jeff Epler 2023-09-26 07:45:01 -05:00
parent 747b6e8d2e
commit 03141d40af
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE

View File

@ -82,6 +82,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
self->sda_pin = sda;
self->scl_pin = scl;
self->i2c_num = peripherals_i2c_get_free_num();
self->has_lock = 0;
if (self->i2c_num == I2C_NUM_MAX) {
mp_raise_ValueError(translate("All I2C peripherals are in use"));