Skip to content

Commit

Permalink
fix(span): explicitly set span->txt to the return value of lv_mem_rea…
Browse files Browse the repository at this point in the history
…lloc(lvgl#3005)

* Update lv_span.c

Explicitly set `span->txt` to return of `lv_mem_realloc`

* Update lv_mem.h

Add note about `lv_mem_realloc` return value on failure
  • Loading branch information
C47D authored Jan 17, 2022
1 parent 138db9c commit a9a6cb8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/extra/widgets/span/lv_span.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void lv_span_set_text(lv_span_t * span, const char * text)
span->txt = lv_mem_alloc(strlen(text) + 1);
}
else {
lv_mem_realloc(span->txt, strlen(text) + 1);
span->txt = lv_mem_realloc(span->txt, strlen(text) + 1);
}
span->static_flag = 0;
strcpy(span->txt, text);
Expand Down
2 changes: 1 addition & 1 deletion src/misc/lv_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void lv_mem_free(void * data);
* @param data pointer to an allocated memory.
* Its content will be copied to the new memory block and freed
* @param new_size the desired new size in byte
* @return pointer to the new memory
* @return pointer to the new memory, NULL on failure
*/
void * lv_mem_realloc(void * data_p, size_t new_size);

Expand Down

0 comments on commit a9a6cb8

Please sign in to comment.