lavfi: handle NULL lists in avfilter_make_format_list

pull/2/head
Mina Nagy Zaki 14 years ago committed by Stefano Sabatini
parent 9e4cb03a93
commit 47d2ca3205
  1. 5
      libavfilter/avfilter.h
  2. 13
      libavfilter/formats.c

@ -27,7 +27,7 @@
#define LIBAVFILTER_VERSION_MAJOR 2 #define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MINOR 14 #define LIBAVFILTER_VERSION_MINOR 14
#define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_MICRO 1
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \ LIBAVFILTER_VERSION_MINOR, \
@ -233,7 +233,8 @@ typedef struct AVFilterFormats {
* Create a list of supported formats. This is intended for use in * Create a list of supported formats. This is intended for use in
* AVFilter->query_formats(). * AVFilter->query_formats().
* *
* @param fmts list of media formats, terminated by -1 * @param fmts list of media formats, terminated by -1. If NULL an
* empty list is created.
* @return the format list, with no existing references * @return the format list, with no existing references
*/ */
AVFilterFormats *avfilter_make_format_list(const int *fmts); AVFilterFormats *avfilter_make_format_list(const int *fmts);

@ -73,15 +73,18 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
AVFilterFormats *avfilter_make_format_list(const int *fmts) AVFilterFormats *avfilter_make_format_list(const int *fmts)
{ {
AVFilterFormats *formats; AVFilterFormats *formats;
int count; int count = 0;
for (count = 0; fmts[count] != -1; count++) if (fmts)
; for (count = 0; fmts[count] != -1; count++)
;
formats = av_mallocz(sizeof(AVFilterFormats)); formats = av_mallocz(sizeof(AVFilterFormats));
formats->formats = av_malloc(sizeof(*formats->formats) * count);
formats->format_count = count; formats->format_count = count;
memcpy(formats->formats, fmts, sizeof(*formats->formats) * count); if (count) {
formats->formats = av_malloc(sizeof(*formats->formats) * count);
memcpy(formats->formats, fmts, sizeof(*formats->formats) * count);
}
return formats; return formats;
} }

Loading…
Cancel
Save