fix: prevent memory leak on lcd initialization error

This commit is contained in:
aZholtikov committed 2026-08-29 09:06:07 +03:00
1 parent 2da7f28835
commit facf8b802b
5 files changed
+5 -5

No files matched your search

+1 -1
View File
@@ -594,4 +594,4 @@ limitations under the License.
--- ---
*Generated for zh_160x_i2c v5.0.0* *Generated for zh_160x_i2c v5.0.1*
+1 -1
View File
@@ -594,4 +594,4 @@ void app_main(void)
--- ---
*Generated for zh_160x_i2c v5.0.0* *Generated for zh_160x_i2c v5.0.1*
+1 -1
View File
@@ -1,6 +1,6 @@
description: ESP32 ESP-IDF component for LCD 1602A/1604A displays via I2C using PCF8574(A) expanders description: ESP32 ESP-IDF component for LCD 1602A/1604A displays via I2C using PCF8574(A) expanders
url: https://github.com/aZholtikov/zh_160x_i2c url: https://github.com/aZholtikov/zh_160x_i2c
version: "5.0.0" version: "5.0.1"
license: "Apache-2.0" license: "Apache-2.0"
maintainers: maintainers:
- "Alexey Zholtikov <alexey.zholtikov@yandex.ru>" - "Alexey Zholtikov <alexey.zholtikov@yandex.ru>"
+1 -1
View File
@@ -1 +1 @@
5.0.0 5.0.1
+1 -1
View File
@@ -90,7 +90,7 @@ esp_err_t zh_160x_init(zh_pcf8574_handle_t **expander, zh_160x_i2c_handle_t **ha
ZH_ERROR_CHECK(*handle != NULL, ESP_ERR_NO_MEM, NULL, "160X initialization failed. Failed to allocate 160X handle."); ZH_ERROR_CHECK(*handle != NULL, ESP_ERR_NO_MEM, NULL, "160X initialization failed. Failed to allocate 160X handle.");
(*handle)->zh_pcf8574_handle = *expander; (*handle)->zh_pcf8574_handle = *expander;
(*handle)->zh_160x_i2c_lcd_size = size; (*handle)->zh_160x_i2c_lcd_size = size;
ZH_ERROR_CHECK(_zh_160x_lcd_init(*handle) == ESP_OK, ESP_FAIL, NULL, "160X initialization failed. PCF8574 error."); ZH_ERROR_CHECK(_zh_160x_lcd_init(*handle) == ESP_OK, ESP_FAIL, heap_caps_free(*handle); *handle = NULL, "160X initialization failed. PCF8574 error.");
ZH_LOGI("160X initialization completed successfully."); ZH_LOGI("160X initialization completed successfully.");
return ESP_OK; return ESP_OK;
} }