History

lavc: handle hw_frames_ctx where necessary

avcodec_copy_context() didn't handle hw_frames_ctx references correctly which could cause crashes.

Andrey Turkin committed 10 years ago

Commit 24b5cff1 parent 4024b561 file · +9 −0Browse files

Unified · Split

libavcodec/options.c+9−0
@@ -190,6 +190,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) · 189 unmodified lines
190190 dest->inter_matrix = NULL;
191191 dest->rc_override = NULL;
192192 dest->subtitle_header = NULL;
193+ dest->hw_frames_ctx = NULL;
193194 #if FF_API_MPV_OPT
194195 FF_DISABLE_DEPRECATION_WARNINGS
195196 dest->rc_eq = NULL;
@@ -219,13 +220,21 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) · 23 unmodified lines
219220 dest->subtitle_header_size = src->subtitle_header_size;
220221 #undef alloc_and_copy_or_fail
221222
223+ if (src->hw_frames_ctx) {
224+ dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);
225+ if (!dest->hw_frames_ctx)
226+ goto fail;
227+ }
228+
222229 return 0;
223230
224231 fail:
232+ av_freep(&dest->subtitle_header);
225233 av_freep(&dest->rc_override);
226234 av_freep(&dest->intra_matrix);
227235 av_freep(&dest->inter_matrix);
228236 av_freep(&dest->extradata);
237+ av_buffer_unref(&dest->hw_frames_ctx);
229238 #if FF_API_MPV_OPT
230239 FF_DISABLE_DEPRECATION_WARNINGS
231240 av_freep(&dest->rc_eq);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t