mirror of
https://github.com/mpv-player/mpv
synced 2025-03-11 08:37:59 +00:00
osd: free buffer allocated with av_malloc with av_free
free() was used before, which could in theory lead to crashes if the OSD buffer was freed or resized. (Whether using free() actually works depends on what function libavutil's av_malloc() uses internally. On Linux, it seems to use memalign(), which uses free() as counterpart for deallocation, so the bug never triggered for me.)
This commit is contained in:
parent
f7e9c15c7b
commit
a62b9cf7a3
@ -99,8 +99,8 @@ void osd_alloc_buf(mp_osd_obj_t* obj)
|
||||
len = obj->stride*(obj->bbox.y2-obj->bbox.y1);
|
||||
if (obj->allocated<len) {
|
||||
obj->allocated = len;
|
||||
free(obj->bitmap_buffer);
|
||||
free(obj->alpha_buffer);
|
||||
av_free(obj->bitmap_buffer);
|
||||
av_free(obj->alpha_buffer);
|
||||
obj->bitmap_buffer = av_malloc(len);
|
||||
obj->alpha_buffer = av_malloc(len);
|
||||
}
|
||||
@ -211,8 +211,8 @@ void osd_free(struct osd_state *osd)
|
||||
mp_osd_obj_t* obj=vo_osd_list;
|
||||
while(obj){
|
||||
mp_osd_obj_t* next=obj->next;
|
||||
free(obj->alpha_buffer);
|
||||
free(obj->bitmap_buffer);
|
||||
av_free(obj->alpha_buffer);
|
||||
av_free(obj->bitmap_buffer);
|
||||
free(obj);
|
||||
obj=next;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user