mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 21:26:43 +00:00
Free font allocations on file open error
This commit is contained in:
parent
cfcaa16ab3
commit
e8f1300193
@ -102,19 +102,19 @@ lv_font_t* hasp_font_load(const char* font_name)
|
||||
|
||||
if(res == LV_FS_RES_OK) {
|
||||
success = lvgl_load_font(&file, font);
|
||||
}
|
||||
|
||||
if(!success) {
|
||||
LOG_WARNING(TAG_FONT, "Error loading font file: %s\n", font_name);
|
||||
/*
|
||||
* When `lvgl_load_font` fails it can leak some pointers.
|
||||
* All non-null pointers can be assumed as allocated and
|
||||
* `lv_font_free` should free them correctly.
|
||||
*/
|
||||
hasp_font_free(font);
|
||||
font = NULL;
|
||||
}
|
||||
lv_fs_close(&file);
|
||||
|
||||
lv_fs_close(&file);
|
||||
if(!success) {
|
||||
LOG_WARNING(TAG_FONT, "Error loading font %s", font_name);
|
||||
/*
|
||||
* When `lvgl_load_font` fails it can leak some pointers.
|
||||
* All non-null pointers can be assumed as allocated and
|
||||
* `lv_font_free` should free them correctly.
|
||||
*/
|
||||
hasp_font_free(font);
|
||||
font = NULL;
|
||||
}
|
||||
|
||||
return font;
|
||||
|
Loading…
x
Reference in New Issue
Block a user