You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avfilter/formats: free the correct pointer in ADD_FORMAT()
Also only free it when it was not previously allocated to return to the state prior to the failing function call Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -314,6 +314,7 @@ AVFilterChannelLayouts *avfilter_make_format64_list(const int64_t *fmts)
|
|||||||
#define ADD_FORMAT(f, fmt, type, list, nb) \
|
#define ADD_FORMAT(f, fmt, type, list, nb) \
|
||||||
do { \
|
do { \
|
||||||
type *fmts; \
|
type *fmts; \
|
||||||
|
void *oldf = *f; \
|
||||||
\
|
\
|
||||||
if (!(*f) && !(*f = av_mallocz(sizeof(**f)))) \
|
if (!(*f) && !(*f = av_mallocz(sizeof(**f)))) \
|
||||||
return AVERROR(ENOMEM); \
|
return AVERROR(ENOMEM); \
|
||||||
@@ -321,7 +322,8 @@ do { \
|
|||||||
fmts = av_realloc((*f)->list, \
|
fmts = av_realloc((*f)->list, \
|
||||||
sizeof(*(*f)->list) * ((*f)->nb + 1));\
|
sizeof(*(*f)->list) * ((*f)->nb + 1));\
|
||||||
if (!fmts) { \
|
if (!fmts) { \
|
||||||
av_freep(&f); \
|
if (!oldf) \
|
||||||
|
av_freep(f); \
|
||||||
return AVERROR(ENOMEM); \
|
return AVERROR(ENOMEM); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
Reference in New Issue
Block a user