mirror of
https://github.com/mpv-player/mpv
synced 2024-12-30 02:52:10 +00:00
vo_opengl: gl_lcms: fix potential dangling pointer issue
If icc-path is set, but the thing is replaced with a memory profile, then p->icc_path would point to deallocated memory. Also, the NULL checks are unnecessary.
This commit is contained in:
parent
5a7719594e
commit
ae8a91d6b6
@ -145,16 +145,17 @@ void gl_lcms_set_options(struct gl_lcms *p, struct mp_icc_opts *opts)
|
|||||||
load_profile(p);
|
load_profile(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Warning: profile.start must point to a ta allocation, and the function
|
||||||
|
// takes over ownership.
|
||||||
void gl_lcms_set_memory_profile(struct gl_lcms *p, bstr *profile)
|
void gl_lcms_set_memory_profile(struct gl_lcms *p, bstr *profile)
|
||||||
{
|
{
|
||||||
if (!p->opts.profile_auto)
|
if (!p->opts.profile_auto)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (p->icc_path)
|
talloc_free(p->icc_path);
|
||||||
talloc_free(p->icc_path);
|
p->icc_path = NULL;
|
||||||
|
|
||||||
if (p->icc_data)
|
talloc_free(p->icc_data);
|
||||||
talloc_free(p->icc_data);
|
|
||||||
|
|
||||||
p->icc_data = talloc_steal(p, profile->start);
|
p->icc_data = talloc_steal(p, profile->start);
|
||||||
p->icc_size = profile->len;
|
p->icc_size = profile->len;
|
||||||
|
Loading…
Reference in New Issue
Block a user