Skip to content

Commit f95ad7b

Browse files
committed
Fix reset pin null reference, construct error null reference
1 parent be19998 commit f95ad7b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

shared-module/displayio/FourWire.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ void common_hal_displayio_fourwire_deinit(displayio_fourwire_obj_t* self) {
7676

7777
common_hal_reset_pin(self->command.pin);
7878
common_hal_reset_pin(self->chip_select.pin);
79-
common_hal_reset_pin(self->reset.pin);
79+
if (self->reset.pin) {
80+
common_hal_reset_pin(self->reset.pin);
81+
}
8082
}
8183

8284
bool common_hal_displayio_fourwire_reset(mp_obj_t obj) {

shared-module/displayio/I2CDisplay.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self,
5353

5454
// Probe the bus to see if a device acknowledges the given address.
5555
if (!common_hal_busio_i2c_probe(i2c, device_address)) {
56+
self->base.type = &mp_type_NoneType;
5657
mp_raise_ValueError_varg(translate("Unable to find I2C Display at %x"), device_address);
5758
}
5859

@@ -71,7 +72,9 @@ void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t* self) {
7172
common_hal_busio_i2c_deinit(self->bus);
7273
}
7374

74-
common_hal_reset_pin(self->reset.pin);
75+
if (self->reset.pin) {
76+
common_hal_reset_pin(self->reset.pin);
77+
}
7578
}
7679

7780
bool common_hal_displayio_i2cdisplay_reset(mp_obj_t obj) {

0 commit comments

Comments
 (0)