diff --git a/lv_objx/lv_img.c b/lv_objx/lv_img.c index a5ae1aa4e..310c5bb1b 100644 --- a/lv_objx/lv_img.c +++ b/lv_objx/lv_img.c @@ -164,7 +164,9 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img) /* If the new and the old src are the same then it was only a refresh.*/ if(ext->src != src_img) { - lv_mem_free(ext->src); + if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_SYMBOL) { + lv_mem_free(ext->src); /*If memory was allocated because of the previous `src_type` then free it*/ + } char * new_str = lv_mem_alloc(strlen(src_img) + 1); lv_mem_assert(new_str); if(new_str == NULL) return;