diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2018-06-08 16:40:29 +0100 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2018-06-12 16:10:31 +0100 |
commit | 238a8ae92fc74fa0f0ac15db5f0fec464db5db7c (patch) | |
tree | 784fc2cccdef7a8d8161bcfbd9ade3ba326eb1b7 | |
parent | 8c20ea8ee0f3f0b27aca0204c6dfaa4ac137e34e (diff) | |
download | ffmpeg-238a8ae92fc74fa0f0ac15db5f0fec464db5db7c.tar.gz |
pixdesc: Only check against valid entries when iterating over lists of enums
Some of these enums have gaps in between their values, since they correspond
to the values in various specs, instead of being an incrementing list.
Fixes segfaults when, for example, using the valid API call:
av_color_primaries_from_name("jecdec-p22");
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
-rw-r--r-- | libavutil/pixdesc.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index ff5c20d50e..96e079584a 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2737,7 +2737,12 @@ int av_color_primaries_from_name(const char *name) int i; for (i = 0; i < FF_ARRAY_ELEMS(color_primaries_names); i++) { - size_t len = strlen(color_primaries_names[i]); + size_t len; + + if (!color_primaries_names[i]) + continue; + + len = strlen(color_primaries_names[i]); if (!strncmp(color_primaries_names[i], name, len)) return i; } @@ -2756,7 +2761,12 @@ int av_color_transfer_from_name(const char *name) int i; for (i = 0; i < FF_ARRAY_ELEMS(color_transfer_names); i++) { - size_t len = strlen(color_transfer_names[i]); + size_t len; + + if (!color_transfer_names[i]) + continue; + + len = strlen(color_transfer_names[i]); if (!strncmp(color_transfer_names[i], name, len)) return i; } @@ -2775,7 +2785,12 @@ int av_color_space_from_name(const char *name) int i; for (i = 0; i < FF_ARRAY_ELEMS(color_space_names); i++) { - size_t len = strlen(color_space_names[i]); + size_t len; + + if (!color_space_names[i]) + continue; + + len = strlen(color_space_names[i]); if (!strncmp(color_space_names[i], name, len)) return i; } @@ -2794,7 +2809,12 @@ int av_chroma_location_from_name(const char *name) int i; for (i = 0; i < FF_ARRAY_ELEMS(chroma_location_names); i++) { - size_t len = strlen(chroma_location_names[i]); + size_t len; + + if (!chroma_location_names[i]) + continue; + + len = strlen(chroma_location_names[i]); if (!strncmp(chroma_location_names[i], name, len)) return i; } |