Skip to content

Commit 64a5328

Browse files
authored
Adding condition before calling av_frame_free (in AV_FREE_FRAME macro) (#184)
1 parent 828990b commit 64a5328

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

include/FFmpegUtilities.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
#define AV_ALLOCATE_FRAME() av_frame_alloc()
142142
#define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) av_image_alloc(av_frame->data, av_frame->linesize, width, height, pix_fmt, 1)
143143
#define AV_RESET_FRAME(av_frame) av_frame_unref(av_frame)
144-
#define AV_FREE_FRAME(av_frame) av_frame_free(av_frame)
144+
#define AV_FREE_FRAME(av_frame) if (av_frame) av_frame_free(av_frame)
145145
#define AV_FREE_PACKET(av_packet) av_packet_unref(av_packet)
146146
#define AV_FREE_CONTEXT(av_context) avcodec_free_context(&av_context)
147147
#define AV_GET_CODEC_TYPE(av_stream) av_stream->codecpar->codec_type
@@ -176,7 +176,7 @@
176176
#define AV_ALLOCATE_FRAME() av_frame_alloc()
177177
#define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) av_image_alloc(av_frame->data, av_frame->linesize, width, height, pix_fmt, 1)
178178
#define AV_RESET_FRAME(av_frame) av_frame_unref(av_frame)
179-
#define AV_FREE_FRAME(av_frame) av_frame_free(av_frame)
179+
#define AV_FREE_FRAME(av_frame) if(av_frame) av_frame_free(av_frame)
180180
#define AV_FREE_PACKET(av_packet) av_packet_unref(av_packet)
181181
#define AV_FREE_CONTEXT(av_context) avcodec_free_context(&av_context)
182182
#define AV_GET_CODEC_TYPE(av_stream) av_stream->codecpar->codec_type
@@ -211,7 +211,7 @@
211211
#define AV_ALLOCATE_FRAME() av_frame_alloc()
212212
#define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) avpicture_alloc((AVPicture *) av_frame, pix_fmt, width, height)
213213
#define AV_RESET_FRAME(av_frame) av_frame_unref(av_frame)
214-
#define AV_FREE_FRAME(av_frame) av_frame_free(av_frame)
214+
#define AV_FREE_FRAME(av_frame) if (av_frame) av_frame_free(av_frame)
215215
#define AV_FREE_PACKET(av_packet) av_packet_unref(av_packet)
216216
#define AV_FREE_CONTEXT(av_context) avcodec_close(av_context)
217217
#define AV_GET_CODEC_TYPE(av_stream) av_stream->codec->codec_type
@@ -241,7 +241,7 @@
241241
#define AV_ALLOCATE_FRAME() avcodec_alloc_frame()
242242
#define AV_ALLOCATE_IMAGE(av_frame, pix_fmt, width, height) avpicture_alloc((AVPicture *) av_frame, pix_fmt, width, height)
243243
#define AV_RESET_FRAME(av_frame) avcodec_get_frame_defaults(av_frame)
244-
#define AV_FREE_FRAME(av_frame) avcodec_free_frame(av_frame)
244+
#define AV_FREE_FRAME(av_frame) if(av_frame) avcodec_free_frame(av_frame)
245245
#define AV_FREE_PACKET(av_packet) av_free_packet(av_packet)
246246
#define AV_FREE_CONTEXT(av_context) avcodec_close(av_context)
247247
#define AV_GET_CODEC_TYPE(av_stream) av_stream->codec->codec_type

0 commit comments

Comments
 (0)