-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(animimage): add NULL pointer check #6206
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a commit to fix the value error in lv_animimg_set_src
?
I think it should be lv_anim_set_values(&animimg->anim, 0, (int32_t)num);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@XuNeo the lv_example_animimg_1
now looks more correct after removing the - 1
.
If you modify lv_animimg_set_repeat_count(animimg0, 1); On the last frame it will set static void index_change(lv_obj_t * obj, int32_t index)
{
int32_t idx;
lv_animimg_t * animimg = (lv_animimg_t *)obj;
idx = index % animimg->pic_count; For good timing we should really remove the if(index >= animimg->pic_count) index = animimg->pic_count - 1; |
This is better. The anim value is mapped directly to the image index, thus @yinntian Could you please update the PR accordingly? |
@XuNeo lv_anim_set_values(&animimg->anim, 0, (int32_t)num); static void index_change(lv_obj_t * obj, int32_t index)
{
int32_t idx;
lv_animimg_t * animimg = (lv_animimg_t *)obj;
if(animimg->dsc == NULL){
return ;
}
if(index >= animimg->pic_count){
index = animimg->pic_count - 1;
}
idx = index % animimg->pic_count;
// debug code -------
static int debug_count = -2;
printf("%d ", idx);
debug_count++;
if(debug_count % 4 == 0){
printf("\n");
}
//-------
lv_image_set_src(obj, animimg->dsc[idx]);
} Looks like the animation is normal But by the output message, the change of 'idx' is a cycle of 0, 1, 2, 2, but the ‘2’ output will immediately output ‘0’, is it possible that there is something wrong with anim in this behavior? |
As you can see this way each image were shown for 1 sec. |
We need some feedback on this pull request. Now we mark this as "stale" because there was no activity here for 14 days. Remove the "stale" label or comment else this will be closed in 7 days. |
Description of the feature or fix
When dsc sets an incorrect NULL value, it can cause the animation's callback function to incorrectly take an array subscript value for the NULL value and cause the program to crash, which should prompt an error message and return.
Notes
lv_conf_template.h
run lv_conf_internal_gen.py and update Kconfig.scripts/code-format.py
(astyle version v3.4.12 needs to be installed) and follow the Code Conventions.