diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index c9668c9a2..1d690e78f 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -1578,14 +1578,17 @@ void lv_obj_set_design_cb(lv_obj_t * obj, lv_design_cb_t design_cb) * Allocate a new ext. data for an object * @param obj pointer to an object * @param ext_size the size of the new ext. data - * @return Normal pointer to the allocated ext + * @return pointer to the allocated ext. + * If out of memory NULL is returned and the original ext is preserved */ void * lv_obj_allocate_ext_attr(lv_obj_t * obj, uint16_t ext_size) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); - obj->ext_attr = lv_mem_realloc(obj->ext_attr, ext_size); + void * new_ext = lv_mem_realloc(obj->ext_attr, ext_size); + if(new_ext == NULL) return NULL; + obj->ext_attr = new_ext; return (void *)obj->ext_attr; } diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index 9899efa74..8cd815cdb 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -247,8 +247,12 @@ void * lv_mem_realloc(void * data_p, size_t new_size) void * new_p; new_p = lv_mem_alloc(new_size); + if(new_p == NULL) { + LV_LOG_WARN("Couldn't allocate memory"); + return NULL; + } - if(new_p != NULL && data_p != NULL) { + if(data_p != NULL) { /*Copy the old data to the new. Use the smaller size*/ if(old_size != 0) { memcpy(new_p, data_p, LV_MATH_MIN(new_size, old_size)); @@ -256,7 +260,6 @@ void * lv_mem_realloc(void * data_p, size_t new_size) } } - if(new_p == NULL) LV_LOG_WARN("Couldn't allocate memory"); return new_p; } diff --git a/src/lv_objx/lv_arc.c b/src/lv_objx/lv_arc.c index a63df14f6..5e6b1ab10 100644 --- a/src/lv_objx/lv_arc.c +++ b/src/lv_objx/lv_arc.c @@ -62,7 +62,10 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the arc type specific extended data*/ lv_arc_ext_t * ext = lv_obj_allocate_ext_attr(new_arc, sizeof(lv_arc_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_arc); + return NULL; + } if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_arc); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_arc); diff --git a/src/lv_objx/lv_bar.c b/src/lv_objx/lv_bar.c index 0a8de0d3f..1eab6e313 100644 --- a/src/lv_objx/lv_bar.c +++ b/src/lv_objx/lv_bar.c @@ -80,7 +80,10 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the object type specific extended data*/ lv_bar_ext_t * ext = lv_obj_allocate_ext_attr(new_bar, sizeof(lv_bar_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_bar); + return NULL; + } ext->min_value = 0; ext->start_value = 0; diff --git a/src/lv_objx/lv_btn.c b/src/lv_objx/lv_btn.c index f097bb57e..f26628394 100644 --- a/src/lv_objx/lv_btn.c +++ b/src/lv_objx/lv_btn.c @@ -87,7 +87,10 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the extended data*/ lv_btn_ext_t * ext = lv_obj_allocate_ext_attr(new_btn, sizeof(lv_btn_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_btn); + return NULL; + } ext->state = LV_BTN_STATE_REL; diff --git a/src/lv_objx/lv_btnm.c b/src/lv_objx/lv_btnm.c index e7f5b5765..9b38a70f3 100644 --- a/src/lv_objx/lv_btnm.c +++ b/src/lv_objx/lv_btnm.c @@ -80,7 +80,10 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the object type specific extended data*/ lv_btnm_ext_t * ext = lv_obj_allocate_ext_attr(new_btnm, sizeof(lv_btnm_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_btnm); + return NULL; + } ext->btn_cnt = 0; ext->btn_id_pr = LV_BTNM_BTN_NONE; diff --git a/src/lv_objx/lv_calendar.c b/src/lv_objx/lv_calendar.c index 089610313..1dd83464f 100644 --- a/src/lv_objx/lv_calendar.c +++ b/src/lv_objx/lv_calendar.c @@ -85,7 +85,11 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the calendar type specific extended data*/ lv_calendar_ext_t * ext = lv_obj_allocate_ext_attr(new_calendar, sizeof(lv_calendar_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_calendar); + return NULL; + } + if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_calendar); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_calendar); diff --git a/src/lv_objx/lv_canvas.c b/src/lv_objx/lv_canvas.c index 9f0401b48..4313c865a 100644 --- a/src/lv_objx/lv_canvas.c +++ b/src/lv_objx/lv_canvas.c @@ -80,7 +80,11 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the canvas type specific extended data*/ lv_canvas_ext_t * ext = lv_obj_allocate_ext_attr(new_canvas, sizeof(lv_canvas_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_canvas); + return NULL; + } + if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_canvas); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_canvas); diff --git a/src/lv_objx/lv_cb.c b/src/lv_objx/lv_cb.c index 08b8ba7f1..383c9c8a5 100644 --- a/src/lv_objx/lv_cb.c +++ b/src/lv_objx/lv_cb.c @@ -65,7 +65,10 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy) lv_cb_ext_t * ext = lv_obj_allocate_ext_attr(new_cb, sizeof(lv_cb_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_cb); + return NULL; + } ext->bullet = NULL; ext->label = NULL; diff --git a/src/lv_objx/lv_chart.c b/src/lv_objx/lv_chart.c index 42fc4ee49..20ea4980e 100644 --- a/src/lv_objx/lv_chart.c +++ b/src/lv_objx/lv_chart.c @@ -96,7 +96,10 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the object type specific extended data*/ lv_chart_ext_t * ext = lv_obj_allocate_ext_attr(new_chart, sizeof(lv_chart_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_chart); + return NULL; + } lv_ll_init(&ext->series_ll, sizeof(lv_chart_series_t)); diff --git a/src/lv_objx/lv_cont.c b/src/lv_objx/lv_cont.c index 9aceea02f..bf4db61d4 100644 --- a/src/lv_objx/lv_cont.c +++ b/src/lv_objx/lv_cont.c @@ -79,7 +79,10 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_allocate_ext_attr(new_cont, sizeof(lv_cont_ext_t)); lv_cont_ext_t * ext = lv_obj_get_ext_attr(new_cont); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_cont); + return NULL; + } LV_ASSERT_MEM(ext); ext->fit_left = LV_FIT_NONE; diff --git a/src/lv_objx/lv_cpicker.c b/src/lv_objx/lv_cpicker.c index 21b055439..aca670083 100644 --- a/src/lv_objx/lv_cpicker.c +++ b/src/lv_objx/lv_cpicker.c @@ -104,7 +104,10 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the extended data*/ lv_cpicker_ext_t * ext = lv_obj_allocate_ext_attr(new_cpicker, sizeof(lv_cpicker_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_cpicker); + return NULL; + } /*Initialize the allocated 'ext' */ ext->type = LV_CPICKER_DEF_TYPE; diff --git a/src/lv_objx/lv_ddlist.c b/src/lv_objx/lv_ddlist.c index 02f56b552..3209ad6bc 100644 --- a/src/lv_objx/lv_ddlist.c +++ b/src/lv_objx/lv_ddlist.c @@ -87,7 +87,10 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the drop down list type specific extended data*/ lv_ddlist_ext_t * ext = lv_obj_allocate_ext_attr(new_ddlist, sizeof(lv_ddlist_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_ddlist); + return NULL; + } /*Initialize the allocated 'ext' */ ext->label = NULL; diff --git a/src/lv_objx/lv_gauge.c b/src/lv_objx/lv_gauge.c index d24e83673..2308f76f1 100644 --- a/src/lv_objx/lv_gauge.c +++ b/src/lv_objx/lv_gauge.c @@ -73,7 +73,10 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the gauge type specific extended data*/ lv_gauge_ext_t * ext = lv_obj_allocate_ext_attr(new_gauge, sizeof(lv_gauge_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_gauge); + return NULL; + } /*Initialize the allocated 'ext' */ ext->needle_count = 0; diff --git a/src/lv_objx/lv_img.c b/src/lv_objx/lv_img.c index 20fd5923c..c78e1d93f 100644 --- a/src/lv_objx/lv_img.c +++ b/src/lv_objx/lv_img.c @@ -72,7 +72,10 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy) /*Extend the basic object to image object*/ lv_img_ext_t * ext = lv_obj_allocate_ext_attr(new_img, sizeof(lv_img_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_img); + return NULL; + } ext->src = NULL; ext->src_type = LV_IMG_SRC_UNKNOWN; diff --git a/src/lv_objx/lv_imgbtn.c b/src/lv_objx/lv_imgbtn.c index 491aa4a85..103c6d801 100644 --- a/src/lv_objx/lv_imgbtn.c +++ b/src/lv_objx/lv_imgbtn.c @@ -62,7 +62,11 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the image button type specific extended data*/ lv_imgbtn_ext_t * ext = lv_obj_allocate_ext_attr(new_imgbtn, sizeof(lv_imgbtn_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_imgbtn); + return NULL; + } + if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_imgbtn); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_imgbtn); diff --git a/src/lv_objx/lv_kb.c b/src/lv_objx/lv_kb.c index 1913316a2..216fc78c5 100644 --- a/src/lv_objx/lv_kb.c +++ b/src/lv_objx/lv_kb.c @@ -108,7 +108,10 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the keyboard type specific extended data*/ lv_kb_ext_t * ext = lv_obj_allocate_ext_attr(new_kb, sizeof(lv_kb_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_kb); + return NULL; + } /*Initialize the allocated 'ext' */ diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index 9211a86d2..a581fead7 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -88,7 +88,10 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy) lv_label_ext_t * ext = lv_obj_get_ext_attr(new_label); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_label); + return NULL; + } ext->text = NULL; ext->static_txt = 0; diff --git a/src/lv_objx/lv_led.c b/src/lv_objx/lv_led.c index 525e287ee..b51bc490b 100644 --- a/src/lv_objx/lv_led.c +++ b/src/lv_objx/lv_led.c @@ -68,7 +68,10 @@ lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the object type specific extended data*/ lv_led_ext_t * ext = lv_obj_allocate_ext_attr(new_led, sizeof(lv_led_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_led); + return NULL; + } ext->bright = LV_LED_BRIGHT_ON; diff --git a/src/lv_objx/lv_line.c b/src/lv_objx/lv_line.c index 4a963c546..d9b25e46b 100644 --- a/src/lv_objx/lv_line.c +++ b/src/lv_objx/lv_line.c @@ -63,7 +63,10 @@ lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy) /*Extend the basic object to line object*/ lv_line_ext_t * ext = lv_obj_allocate_ext_attr(new_line, sizeof(lv_line_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_line); + return NULL; + } ext->point_num = 0; ext->point_array = NULL; diff --git a/src/lv_objx/lv_list.c b/src/lv_objx/lv_list.c index 8db34d7e3..f29f555dc 100644 --- a/src/lv_objx/lv_list.c +++ b/src/lv_objx/lv_list.c @@ -79,7 +79,10 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy) lv_list_ext_t * ext = lv_obj_allocate_ext_attr(new_list, sizeof(lv_list_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_list); + return NULL; + } ext->style_img = NULL; ext->styles_btn[LV_BTN_STATE_REL] = &lv_style_btn_rel; diff --git a/src/lv_objx/lv_lmeter.c b/src/lv_objx/lv_lmeter.c index 5e2e05325..e451ff677 100644 --- a/src/lv_objx/lv_lmeter.c +++ b/src/lv_objx/lv_lmeter.c @@ -64,7 +64,10 @@ lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the line meter type specific extended data*/ lv_lmeter_ext_t * ext = lv_obj_allocate_ext_attr(new_lmeter, sizeof(lv_lmeter_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_lmeter); + return NULL; + } /*Initialize the allocated 'ext' */ ext->min_value = 0; diff --git a/src/lv_objx/lv_mbox.c b/src/lv_objx/lv_mbox.c index f56904cb0..604e798e8 100644 --- a/src/lv_objx/lv_mbox.c +++ b/src/lv_objx/lv_mbox.c @@ -78,7 +78,10 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the message box type specific extended data*/ lv_mbox_ext_t * ext = lv_obj_allocate_ext_attr(new_mbox, sizeof(lv_mbox_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_mbox); + return NULL; + } ext->text = NULL; ext->btnm = NULL; diff --git a/src/lv_objx/lv_objmask.c b/src/lv_objx/lv_objmask.c index ef4694a22..1d426e92d 100644 --- a/src/lv_objx/lv_objmask.c +++ b/src/lv_objx/lv_objmask.c @@ -60,7 +60,11 @@ lv_obj_t * lv_objmask_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the object mask type specific extended data*/ lv_objmask_ext_t * ext = lv_obj_allocate_ext_attr(new_objmask, sizeof(lv_objmask_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_objmask); + return NULL; + } + if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_objmask); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_objmask); diff --git a/src/lv_objx/lv_objx_templ.c b/src/lv_objx/lv_objx_templ.c index 81bb71e7b..aebefb4b9 100644 --- a/src/lv_objx/lv_objx_templ.c +++ b/src/lv_objx/lv_objx_templ.c @@ -68,7 +68,11 @@ lv_obj_t * lv_templ_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the template type specific extended data*/ lv_templ_ext_t * ext = lv_obj_allocate_ext_attr(new_templ, sizeof(lv_templ_ext_t)); lv_mem_assert(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_templ); + return NULL; + } + if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_templ); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_templ); diff --git a/src/lv_objx/lv_page.c b/src/lv_objx/lv_page.c index 6682b7f80..9b4002bbd 100644 --- a/src/lv_objx/lv_page.c +++ b/src/lv_objx/lv_page.c @@ -89,7 +89,10 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the object type specific extended data*/ lv_page_ext_t * ext = lv_obj_allocate_ext_attr(new_page, sizeof(lv_page_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_page); + return NULL; + } ext->scrl = NULL; ext->sb.hor_draw = 0; diff --git a/src/lv_objx/lv_preload.c b/src/lv_objx/lv_preload.c index 4b9a5d6ed..b00bb8cb5 100644 --- a/src/lv_objx/lv_preload.c +++ b/src/lv_objx/lv_preload.c @@ -75,7 +75,10 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the pre loader type specific extended data*/ lv_preload_ext_t * ext = lv_obj_allocate_ext_attr(new_preload, sizeof(lv_preload_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_preload); + return NULL; + } if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_preload); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_preload); diff --git a/src/lv_objx/lv_roller.c b/src/lv_objx/lv_roller.c index cc15880b8..dbd0a79f6 100644 --- a/src/lv_objx/lv_roller.c +++ b/src/lv_objx/lv_roller.c @@ -77,7 +77,10 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the roller type specific extended data*/ lv_roller_ext_t * ext = lv_obj_allocate_ext_attr(new_roller, sizeof(lv_roller_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_roller); + return NULL; + } ext->mode = LV_ROLLER_MODE_NORMAL; diff --git a/src/lv_objx/lv_slider.c b/src/lv_objx/lv_slider.c index cb6c24e9f..79a00042f 100644 --- a/src/lv_objx/lv_slider.c +++ b/src/lv_objx/lv_slider.c @@ -70,7 +70,10 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the slider type specific extended data*/ lv_slider_ext_t * ext = lv_obj_allocate_ext_attr(new_slider, sizeof(lv_slider_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_slider); + return NULL; + } /*Initialize the allocated 'ext' */ ext->style_knob = &lv_style_pretty; diff --git a/src/lv_objx/lv_spinbox.c b/src/lv_objx/lv_spinbox.c index 2f2aa4983..914f7afe3 100644 --- a/src/lv_objx/lv_spinbox.c +++ b/src/lv_objx/lv_spinbox.c @@ -61,7 +61,11 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the spinbox type specific extended data*/ lv_spinbox_ext_t * ext = lv_obj_allocate_ext_attr(new_spinbox, sizeof(lv_spinbox_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_spinbox); + return NULL; + } + if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_spinbox); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_spinbox); diff --git a/src/lv_objx/lv_sw.c b/src/lv_objx/lv_sw.c index 3ea3b5d01..8ceaab05d 100644 --- a/src/lv_objx/lv_sw.c +++ b/src/lv_objx/lv_sw.c @@ -72,7 +72,10 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the switch type specific extended data*/ lv_sw_ext_t * ext = lv_obj_allocate_ext_attr(new_sw, sizeof(lv_sw_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_sw); + return NULL; + } /*Initialize the allocated 'ext' */ ext->changed = 0; diff --git a/src/lv_objx/lv_ta.c b/src/lv_objx/lv_ta.c index 07327473d..66e174502 100644 --- a/src/lv_objx/lv_ta.c +++ b/src/lv_objx/lv_ta.c @@ -98,7 +98,10 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the object type specific extended data*/ lv_ta_ext_t * ext = lv_obj_allocate_ext_attr(new_ta, sizeof(lv_ta_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_ta); + return NULL; + } ext->cursor.state = 1; ext->pwd_mode = 0; diff --git a/src/lv_objx/lv_table.c b/src/lv_objx/lv_table.c index b4f60e851..a7ff1ffef 100644 --- a/src/lv_objx/lv_table.c +++ b/src/lv_objx/lv_table.c @@ -64,7 +64,11 @@ lv_obj_t * lv_table_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the table type specific extended data*/ lv_table_ext_t * ext = lv_obj_allocate_ext_attr(new_table, sizeof(lv_table_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_table); + return NULL; + } + if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_table); if(ancestor_scrl_design == NULL) ancestor_scrl_design = lv_obj_get_design_cb(new_table); diff --git a/src/lv_objx/lv_tabview.c b/src/lv_objx/lv_tabview.c index a6d8958cb..a306a9531 100644 --- a/src/lv_objx/lv_tabview.c +++ b/src/lv_objx/lv_tabview.c @@ -81,7 +81,10 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the tab type specific extended data*/ lv_tabview_ext_t * ext = lv_obj_allocate_ext_attr(new_tabview, sizeof(lv_tabview_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_tabview); + return NULL; + } /*Initialize the allocated 'ext' */ ext->tab_cur = 0; diff --git a/src/lv_objx/lv_tileview.c b/src/lv_objx/lv_tileview.c index 843ff91fc..a8e6598bc 100644 --- a/src/lv_objx/lv_tileview.c +++ b/src/lv_objx/lv_tileview.c @@ -74,7 +74,11 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the tileview type specific extended data*/ lv_tileview_ext_t * ext = lv_obj_allocate_ext_attr(new_tileview, sizeof(lv_tileview_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_tileview); + return NULL; + } + if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_tileview); if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_tileview)); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_tileview); diff --git a/src/lv_objx/lv_win.c b/src/lv_objx/lv_win.c index 03c689a0f..e0be314f6 100644 --- a/src/lv_objx/lv_win.c +++ b/src/lv_objx/lv_win.c @@ -61,7 +61,10 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy) /*Allocate the object type specific extended data*/ lv_win_ext_t * ext = lv_obj_allocate_ext_attr(new_win, sizeof(lv_win_ext_t)); LV_ASSERT_MEM(ext); - if(ext == NULL) return NULL; + if(ext == NULL) { + lv_obj_del(new_win); + return NULL; + } ext->page = NULL; ext->header = NULL;